Vue js; Vue路由器不是简单路由中的构造函数错误 [英] Vue js;Vue router is not constructor error in simple route

查看:257
本文介绍了Vue js; Vue路由器不是简单路由中的构造函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用官方路由库实现简单的路由.

I am trying to implement simple routing with official route library.

这是我的 app.js

 window.Vue = require('vue');
    window.VueRouter= require('vue-router');

    Vue.use(VueRouter);

const vt=Vue.component('example', require('./components/Example.vue'));

const router = new VueRouter({
      routes:[
        {
          path:'/test',
          component:vt
        }
    ]
})

const app = new Vue({
    el: '#app',
    router:router
});

但是我遇到了错误

app.js:11256未捕获的TypeError:VueRouter不是构造函数

app.js:11256 Uncaught TypeError: VueRouter is not a constructor

推荐答案

基于我最终通过导入解决的注释

Based on the comments finally i resolved with this import

import VueRouter from 'vue-router';
Vue.use(VueRouter);

这篇关于Vue js; Vue路由器不是简单路由中的构造函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆