import Vue from 'vue'
import {Button} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import router from './index.js'
import Home from '../Home.vue'
Vue.config.productionTip = false
Vue.use(Button);
Vue.use(router);
Vue.use(Home);
new Vue({
render: h => h(App),
router
}).$mount('#app')
main.js代码
import Vue from 'vue'
import Router from 'vue-router'
// import Home from '../views/Home.vue'
Vue.use(Router)
const routes = [
{
path: '/',
component: () => import('./components/HelloWorld.vue')
},
{
path: '/Laker',
component: () => import('./components/Laker.vue')
},
{
path : '/Dallas',
component: () => import('./components/Dallas.vue')
},
{
path:'*', redirect:'/'
}
]
const router = new Router({
mode:"hash",
routes
})
export default router
index.js代码块
最重要的是链接每个文件的路径,../和./有时候区分不好的话会一直报错
我一直有报错,最后把所有的要在main.js里引用的文件放在同一个目录里,没有上下级路径,index.js从router文件夹中取出,Home.vue从Views中取出,才能跑出来