我已经安装了 vue-router (在 Laravel 项目中),然后尝试使用它:
import VueRouter from 'vue-router'
Vue.use(VueRouter)
然后我得到这个:
[Vue warn]: Error in beforeCreate hook: "TypeError: this._router.init is not a function"
有趣的是,之前一切都很好,但突然开始收到这条消息。
Replace vue
with vue-loader
在你的 Webpack 配置中https://github.com/vuejs/vue-loader/issues/409 https://github.com/vuejs/vue-loader/issues/409
UPDATE
好吧,显然您正在以独特的方式初始化路由器。也许您正在构建一个状态标签应用程序而不是单页应用程序。
require('./bootstrap');
import Vue from 'vue'
import VueRouter from 'vue-router'
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
let home = require('./components/Home.vue'));
let buy = require('./components/Buy.vue');
let home = require('./components/Home.vue');
let sell = require('./components/Sell.vue');
let wallet = require('./components/Wallet.vue');
const routes = [{
path: '/',
component: home
},
{
path: '/buy',
component: buy
},
{
path: '/sell',
component: sell
},
{
path: '/wallet',
component: wallet
}
];
const router = new VueRouter
({
mode: 'history',
routes
})
Vue.use(VueRouter);
window.app = new Vue({
el: '#app',
router,
render: h => h(home)
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)