Use vue. js to select all checkbox and batch Delete instance code

Source: Internet
Author: User
This article describes how to use vue. js implements the entire checkbox selection and multiple deletion functions. For more information about how to use vue, see the following article. js implements the entire checkbox selection and multiple deletion functions. For more information, see

Template code:

  
  

  • {Item. name }}
  • :
Delete{SelectArr }} 1Select All

Script:

Script var proData = [{"name": "j1ax" },{ "name": "j2ax" },{ "name": "j3ax "}, {"name": "j4ax"}] export default {name: 'hello', data () {return {proData: proData, selectArr: [] }}, created () {this. $ http. get ('/api/home '). then (function (response) {response = response. body; this. proData = response. data;})}, methods: {del () {let arr = []; var len = this. proData. length; for (var I = 0; I <len; I ++) {if (this. selectArr. indexOf (I)> = 0) {console. log (this. selectArr. indexOf (I)} else {arr. push (proData [I])} this. proData = arr; this. selectArr = []}, selectAll (event) {var _ this = this; console. log (event. currentTarget) if (! Event. currentTarget. checked) {this. selectArr = [];} else {// select all _ this. selectArr = []; _ this. proData. forEach (function (item, I) {_ this. selectArr. push (I) ;}}}} script

The above is the detailed content of the Instance code that implements the full selection and batch deletion function of checkbox Based on vue. js. For more information, see other related articles in the first PHP community!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.