data中有嵌套,取值要链式取

talk is cheap ,show you my code:

<template>
  <div class="">
    BackTop2
    <div>

      <h1>{{abc.def.hij}}</h1>
      <input v-model="abc.def.hij"/>


      <el-button type="primary" @click="btnClicked">主要按钮1</el-button>

    </div>
  </div>

</template>


<script>



export default {

  name: 'BackTop2',
  components: {

  },
  methods:{
    btnClicked(){
      this.abc.def.hij = "点击按钮更换值"
    }
  },
  data(){
    return{
      abc:{
        def:{
          hij:'最里面'
        }
      }
    }
  }

}
</script>

<style>

</style>

 

posted @ 2020-10-10 10:37  liuw_flexi  阅读(209)  评论(0编辑  收藏  举报