Method to extract Vue.js Bootstrap table row ID and collect data attributes-PHP Chinese Network Q&A
Method to extract Vue.js Bootstrap table row ID and collect data attributes
P粉553428780
P粉553428780 2023-09-15 09:24:15
0
1
376

I'm using a Vue.js Bootstrap table and I want to be able to collect the id of each table row into an array or object data property.

This is an example of a Bootstrap table template:

So, how do I collect the values ofrow.item.idinto an array or object so that I can use this data for other purposes?

P粉553428780
P粉553428780

reply all (1)
P粉670107661

You can store any property in the items array into a separate array by iterating using the Array.map() method.

For example:

data() { return { items: [ { id: 1, age: 40, first_name: 'Dickerson', last_name: 'Macdonald' }, { id: 2, age: 21, first_name: 'Larsen', last_name: 'Shaw' }, { id: 3, age: 89, first_name: 'Geneva', last_name: 'Wilson' }, { id: 4, age: 38, first_name: 'Jami', last_name: 'Carney' } ], itemsID: [] } }

Then in the mounted hook:

mounted() { this.itemsID = this.items.map(({id}) => id) }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!