天天看点

vue中关于this.$set的用法

vue中关于this.$se的用法

<template>
  <div>
  <div v-for="(item,index) in list"
  :key="index">
    {{item.name}}
  </div>
  <el-button @click="changeValue" type="primary">改变值</el-button>
  </div>
</template>

<script>
  export default {
      data() {
          return {
              list :[
                  {name: 'meihua', id : 1},
                  {name: 'taohua', id : 2}
              ]
          }
      },
      methods:{
          changeValue(){
              // this.$set(this.list,2, {name:'andy',id:1}) 
              this.list.push({name:'wilson',id:3})
          }
      }
  }

</script>
           

继续阅读