国外logo设计网站推荐,网页浏览器证书失效怎么修复,淘宝网站那个做的,微信小程序直播平台template模板中如何避免
提前处理v-for循环所用的数据#xff0c;不要在v-for循环中去读取数组、对象类型的数据。在上述template模板中滥用this的例子中可以这样优化。
假设list、arr、obj皆是服务端返回来的数据#xff0c;且arr和obj没有用到任何模块渲染中#xff0c;…template模板中如何避免
提前处理v-for循环所用的数据不要在v-for循环中去读取数组、对象类型的数据。在上述template模板中滥用this的例子中可以这样优化。
假设list、arr、obj皆是服务端返回来的数据且arr和obj没有用到任何模块渲染中可以这样优化
优化前
templatediv classwrapdiv v-foritem in listdiv {{ arr[item.index][name] }} /divdiv {{ obj[item.id][age] }} /div/div/div
/template优化后
templatediv classwrapdiv v-foritem in listDatadiv{{item.name}} /divdiv{{item.age}}/div/div/div
/template
script
const arr [];
const obj {}
export default {data() {return {list: [],}},computed: {listData: function ({list}) {list.forEach(item {item.name arr[item.index].name;item.age obj[item.id].age;})return list;}},
}
/script