一,模板应用也就是对DOM的操作
二,如何使用
通过标签里面添加ref 和vue中使用 this.$refs.ref的名字.操作 进行使用
<template>
<h3>模板引用</h3>
<div ref="cont" class="cont">{{ content }}</div>
<input type="text" ref="username">
<button @click="getcont()">获得元素</button>
</template>
<script>
export default{
data(){
return{
content:"内容"
}
},
methods:{
getcont(){
console.log(this.$refs.cont.innerHTHL="不遗憾");
console.log(this.$refs.username.value);
}
}
}
</script>