如何获取dom?
当然是我们的refs方法啦
有两种具体的使用方法
第一种:使用this.$refs.绑定我们设置的名字,放在methods里获取
第二种:使用e.target方法

具体事例:

<div class=“a” ref=“ok”>a</div>
<script>里的methods
    methods:{
        a:function(){
            var getOk = this.$refs.ok.innerText;
            console.log(getOk);//a
    }
另外一种
    methods:{
        a:function(0{
            var el = e.target;
            console.log(el);
            //<div class=“a” >a</div>
    }

Winnie
12 声望0 粉丝