<template>
<view>
<div v-for=”item in list” :key=”item.id”>
{{ item.name }}{{ item.age }}
</div>
</view>
</template>
<script>
export default {
data() {
return {
list:[{id: 1,name: ‘张三’},
{id: 2,name: ‘李四’},
{id: 3,name: ‘王五’}]
}
},
onLoad() {
setTimeout(() => {
const first = this.list[0]
first.age = 18
————
// 方法一
first.age = 18
this.$set(this.list, ‘list’, this.list)
————
// 方法二 (不推荐,影响性能)
first.age = 18
this.$forceUpdate()
————
// 方法三
this.$set(first, ‘age’, 18)
————
}, 1000);
},
}
</script>