鍍金池/ 問答/HTML/ vue 刷新時會觸發(fā)created 和mounted 中的操作但是修改東西之后保

vue 刷新時會觸發(fā)created 和mounted 中的操作但是修改東西之后保存熱更新的時候 樣式會去掉。

當(dāng)vue文件刷新時頁面的效果圖:

clipboard.png

此時查看代碼的時候會有行內(nèi)樣式:

<p id="select01" style="background-color: green; color: red;">haha</p>

但是做了一些更改然后保存的時候樣式會去掉:

clipboard.png

行內(nèi)樣式?jīng)]了

請問這個是什么原因呢?

回答
編輯回答
傻丟丟
 created() {
    Vue.nextTick(() => {
      let select_created01 = document.getElementById("select01");
      select_created01.style.color = "red";
    });
  },
  mounted() {
    // alert("hah");
    let select_mounted01 = document.getElementById("select01");
    select_mounted01.style.backgroundColor = "green";
    console.log(select_mounted01);
    this.$nextTick(() => {});
  },
2018年3月5日 08:16