【发布时间】:2017-04-21 04:50:40
【问题描述】:
将 Vue 实例附加到 HTML 元素时,我可以通过两种方式进行。
- 通过属性引用,el:"#rooty"
- 通过方法调用,$mount("#rooty")
我无法在他们之间做出决定。它们是否完全等价?如果一个更新或过时,推荐哪一个?还有其他区别吗?在这种情况下,会是什么?
按属性引用。
const app = new Vue({
store,
router,
el: "#rooty",
...
});//.$mount("#rooty");
通过方法调用。
const app = new Vue({
store,
router,
//el: "#rooty",
...
}).$mount("#rooty");
【问题讨论】:
标签: javascript html vue.js vue-router vuex