关于vue.js:Vue-thisrefs的使用

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <div id="test" ref="div1">
        <input type="text" ref="input1" name="name" />
        <button @click="add">增加</button>
    </div>  
  </div>

</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  methods:{
      add(){
        // this.$refs.input1.value  = '22';
        let input1 = this.$refs.input1;
        let div1 = this.$refs.div1;
        console.log(input1,div1);
      }
    }
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理