vue 在mounted里操作DOM
this.$nextTick<template><div class="hello"><div><button id="firstBtn" ref="aa">{{testMsg}}</button></div></div></template><script>export default {
·
this.$nextTick
<template>
<div class="hello">
<div>
<button id="firstBtn" ref="aa">{{testMsg}}</button>
</div>
</div>
</template>
<script>
export default {
name: "HelloWorld",
data() {
return {
testMsg: "原始值"
};
},
created() {},
mounted() {
let that = this;
that.$refs.aa.innerHTML = "sss";
that.$nextTick(function() {
console.log(that.$refs.aa.innerHTML);
});
},
methods: {}
};
</script>
更多推荐
已为社区贡献4条内容
所有评论(0)