vue.js 2中的calculated和mounted之间的主要区别是什么?

Ada*_*Jha 0 vue.js vuejs2

当我加入 computed() ,而不是 mounted() 它抛出一个错误

export default {
  components: {
    MainLayout
  },
  mounted(){
    var x = document.getElementById('homeTabPanes');
    // x.style.background = "blue";
    console.log("check the value of x", x);
  }
}
Run Code Online (Sandbox Code Playgroud)

Moh*_*_PH 5

计算是一个包含返回数据的方法的对象,被挂载是在实例被挂载后执行的救生钩,查看指向文档的链接,它的确有很好的解释