脚手架项目在main.js中定义了路由,需要把main.js中的路由配置删除,然后把自己写的路由文件(我的是index.js)重新引用一下。
之前的代码,划线的部分删除。
// 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 Vuefrom 'vue'
import FastClick from 'fastclick'
import VueRouterfrom 'vue-router'
import Appfrom './App'
import Homefrom './pages/Home'
Vue.use(VueRouter)
const routes = [{
path:'/',
component: Home
}]
const router =new VueRouter({
routes
})
FastClick.attach(document.body)
Vue.config.productionTip =false
/* eslint-disable no-new */
new Vue({
router,
render: h => h(App)
}).$mount('#app-box')
改完之后的
// 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 Vuefrom 'vue'
import FastClick from 'fastclick'
import VueRouterfrom 'vue-router'
import Appfrom './App'
import routerfrom './router'
Vue.use(VueRouter)
FastClick.attach(document.body)
Vue.config.productionTip =false
/* eslint-disable no-new */
new Vue({
router,
render: h => h(App)
}).$mount('#app-box')