Vue.js を導入するとコンソールエラーになるとき
4221 ワード
環境
- vuejs v2.5.13
- gulp v3.9.1
実行コード
app.js
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
const router = new VueRouter({
routes
})
const app = new Vue({
router
}).$mount('#app')
コンソールエラー
Router [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
解決策
package.json
"browser": {
"vue": "vue/dist/vue.common.js"
},
Ref.
app.js
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
const router = new VueRouter({
routes
})
const app = new Vue({
router
}).$mount('#app')
コンソールエラー
Router [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
解決策
package.json
"browser": {
"vue": "vue/dist/vue.common.js"
},
Ref.
Router [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
package.json
"browser": {
"vue": "vue/dist/vue.common.js"
},
Ref.
https://router.vuejs.org/ja/essentials/getting-started.html
https://aloerina01.github.io/javascript/vue/2017/03/08/1.html
Author And Source
この問題について(Vue.js を導入するとコンソールエラーになるとき), 我々は、より多くの情報をここで見つけました https://qiita.com/naoiwata/items/7309db1b68134e06453c著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .