坑
因为视频是vue-router是2.0,现在安装的是3.0
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './App';
import goods from './components/goods/goods';
import ratings from './components/ratings/ratings';
import seller from './components/seller/seller';import './common/stylus/index.styl';
// Vue.use(VueRouter); 要把router注入到vue里
// https://segmentfault.com/q/1010000008002386 题解
Vue.use(VueRouter);
// *****************************
const routes = [
{path: '/', redirect: 'goods'},
{ path: '/goods', component: goods },
{ path: '/ratings', component: ratings },
{ path: '/seller', component: seller }
];const router = new VueRouter({
linkActiveClass: 'active',
routes
});
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>',
router
});
// router.go('/goods');