vue 在mounted里操作DOM

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>


你可能感兴趣的:(前端基础学习笔记,vue.js,javascript,前端)