In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how vue defines array objects related knowledge, detailed and easy to understand, simple and fast operation, with certain reference value, I believe everyone will have some gains after reading this article how vue defines array objects, let's take a look at it.
The specific steps are as follows:
1. First, create a vue.js project in vue-cli;
vue create project-name
2.After the vue.js project is created, use the personQueryList method in the project to define an array object;
personQueryList(this.paramType).then(res => {
for (let i = 0; i
< res.records.length;="" i++)="">this.options[i] = {
label: res.records[i].name,
value: res.records[i].code
}
}
})
Related extensions:
1) De-duplication of array objects
methods:{
unique(arr) { //Filter array by unique identifier orderId
const res = new Map();
return arr.filter((arr) => ! res.has(arr.OrderId) && res.set(arr.OrderId, 1))
},
}
this.arr = this.unique(this.arr);
2. Sort array objects
created() {
this.$ axios.run(***, (res) => {
if (res.code === 0) {
this.arr= res.data;
this.arr.sort(this.compare('code'));
this.selectInit(res.data);
}
});
this.onInit();
},
methods: {
compare(property) {
return function(a, b) {
let value1 = a[property];
let value2 = b[property];
return value1 - value2;
};
},
About "vue how to define array object" the content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "how to define array objects in vue." If you still want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.