|
@@ -7,7 +7,30 @@ import VueRouter from 'vue-router'
|
|
import * as Api from './common/api'
|
|
import * as Api from './common/api'
|
|
import * as common from './common/common'
|
|
import * as common from './common/common'
|
|
|
|
|
|
|
|
+Vue.use(VueRouter);
|
|
|
|
+
|
|
|
|
+//1.创建组件
|
|
|
|
+import Home from './components/Home.vue';
|
|
|
|
+import News from './components/News.vue';
|
|
|
|
+import Content from './components/Content.vue';
|
|
|
|
+import Pcontent from './components/Pcontent.vue';
|
|
|
|
+
|
|
|
|
+//2.配置路由
|
|
|
|
+const routes = [
|
|
|
|
+ { path: '/home', component: Home },
|
|
|
|
+ { path: '/news', component: News },
|
|
|
|
+ { path: '/content/:aid', component: Content }, /*动态路由*/
|
|
|
|
+ { path: '/pcontent', component: Pcontent },
|
|
|
|
+ { path: '*', redirect: '/home' } /*默认跳转路由*/
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+//3.实例化VueRouter
|
|
|
|
+const router = new VueRouter({
|
|
|
|
+ routes // (缩写)相当于 routes: routes
|
|
|
|
+})
|
|
|
|
+
|
|
new Vue({
|
|
new Vue({
|
|
el: '#app',
|
|
el: '#app',
|
|
|
|
+ router,
|
|
render: h => h(App)
|
|
render: h => h(App)
|
|
})
|
|
})
|