实例化Vue时的两种挂载方式el与$mount

1.el

new Vue({
  el: '#app',
  data: obj
})
<div id="app">
  <p>{{ foo }}</p>
  <!-- 这里的 `foo` 不会更新! -->
  <button v-on:click="foo = 'baz'">Change it</button>
</div>

2.$mount

const app = new Vue({
    router,
    i18n,
    ...App
}).$mount('#app')
<div id="app">
    <h1 style="font-size: 16px; text-align: center;">{{ $t("message.hello") }}</h1>
</div>
posted @ 2019-11-07 14:09  千年轮回  阅读(1475)  评论(0编辑  收藏  举报