diff --git a/20_脚手架/vue_code/27.src_路由基础示例/App.vue b/20_脚手架/vue_code/27.src_路由基础示例/App.vue new file mode 100644 index 0000000..01573f5 --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/App.vue @@ -0,0 +1,32 @@ + + + diff --git a/20_脚手架/vue_code/27.src_路由基础示例/assets/logo.png b/20_脚手架/vue_code/27.src_路由基础示例/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/20_脚手架/vue_code/27.src_路由基础示例/assets/logo.png differ diff --git a/20_脚手架/vue_code/27.src_路由基础示例/components/Banner.vue b/20_脚手架/vue_code/27.src_路由基础示例/components/Banner.vue new file mode 100644 index 0000000..ea3040a --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/components/Banner.vue @@ -0,0 +1,11 @@ + + + diff --git a/20_脚手架/vue_code/27.src_路由基础示例/main.js b/20_脚手架/vue_code/27.src_路由基础示例/main.js new file mode 100644 index 0000000..9c406ac --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/main.js @@ -0,0 +1,23 @@ +// 引入Vue +import Vue from "vue"; +// 引入App +import App from "./App"; +// 引入VueRouter +import VueRouter from "vue-router"; +// 引入router +import router from "@/router"; + +// 设置Vue +Vue.config.productionTip = false + +// 使用插件 +Vue.use(VueRouter) + +// 实例化Vue +new Vue({ + components: { + App + }, + render: h => h(App), + router: router, +}).$mount('#app') diff --git a/20_脚手架/vue_code/27.src_路由基础示例/pages/About.vue b/20_脚手架/vue_code/27.src_路由基础示例/pages/About.vue new file mode 100644 index 0000000..26560f1 --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/pages/About.vue @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/27.src_路由基础示例/pages/Home.vue b/20_脚手架/vue_code/27.src_路由基础示例/pages/Home.vue new file mode 100644 index 0000000..695efa3 --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/pages/Home.vue @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/27.src_路由基础示例/router/index.js b/20_脚手架/vue_code/27.src_路由基础示例/router/index.js new file mode 100644 index 0000000..55c985e --- /dev/null +++ b/20_脚手架/vue_code/27.src_路由基础示例/router/index.js @@ -0,0 +1,19 @@ +import VueRouter from "vue-router"; + +// 引入组件 +import About from "@/pages/About.vue" +import Home from "@/pages/Home.vue" + +// 创建一个路由器 +export default new VueRouter({ + routes: [ + { + path: '/about', + component: About + }, + { + path: '/home', + component: Home + }, + ] +}) diff --git a/20_脚手架/vue_code/28.src_嵌套路由/App.vue b/20_脚手架/vue_code/28.src_嵌套路由/App.vue new file mode 100644 index 0000000..01573f5 --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/App.vue @@ -0,0 +1,32 @@ + + + diff --git a/20_脚手架/vue_code/28.src_嵌套路由/assets/logo.png b/20_脚手架/vue_code/28.src_嵌套路由/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/20_脚手架/vue_code/28.src_嵌套路由/assets/logo.png differ diff --git a/20_脚手架/vue_code/28.src_嵌套路由/components/Banner.vue b/20_脚手架/vue_code/28.src_嵌套路由/components/Banner.vue new file mode 100644 index 0000000..ea3040a --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/components/Banner.vue @@ -0,0 +1,11 @@ + + + diff --git a/20_脚手架/vue_code/28.src_嵌套路由/main.js b/20_脚手架/vue_code/28.src_嵌套路由/main.js new file mode 100644 index 0000000..9c406ac --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/main.js @@ -0,0 +1,23 @@ +// 引入Vue +import Vue from "vue"; +// 引入App +import App from "./App"; +// 引入VueRouter +import VueRouter from "vue-router"; +// 引入router +import router from "@/router"; + +// 设置Vue +Vue.config.productionTip = false + +// 使用插件 +Vue.use(VueRouter) + +// 实例化Vue +new Vue({ + components: { + App + }, + render: h => h(App), + router: router, +}).$mount('#app') diff --git a/20_脚手架/vue_code/28.src_嵌套路由/pages/About.vue b/20_脚手架/vue_code/28.src_嵌套路由/pages/About.vue new file mode 100644 index 0000000..26560f1 --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/pages/About.vue @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/28.src_嵌套路由/pages/Home.vue b/20_脚手架/vue_code/28.src_嵌套路由/pages/Home.vue new file mode 100644 index 0000000..f40e1c1 --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/pages/Home.vue @@ -0,0 +1,36 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/28.src_嵌套路由/pages/Message.vue b/20_脚手架/vue_code/28.src_嵌套路由/pages/Message.vue new file mode 100644 index 0000000..b557cea --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/pages/Message.vue @@ -0,0 +1,15 @@ + + + diff --git a/20_脚手架/vue_code/28.src_嵌套路由/pages/News.vue b/20_脚手架/vue_code/28.src_嵌套路由/pages/News.vue new file mode 100644 index 0000000..a8d4f7b --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/pages/News.vue @@ -0,0 +1,15 @@ + + + diff --git a/20_脚手架/vue_code/28.src_嵌套路由/router/index.js b/20_脚手架/vue_code/28.src_嵌套路由/router/index.js new file mode 100644 index 0000000..841b7b5 --- /dev/null +++ b/20_脚手架/vue_code/28.src_嵌套路由/router/index.js @@ -0,0 +1,31 @@ +import VueRouter from "vue-router"; + +// 引入组件 +import About from "@/pages/About.vue" +import Home from "@/pages/Home.vue" +import News from "@/pages/News.vue" +import Message from "@/pages/Message.vue"; + +// 创建一个路由器 +export default new VueRouter({ + routes: [ + { + path: '/about', + component: About + }, + { + path: '/home', + component: Home, + children: [ + { + path: 'news', + component: News, + }, + { + path: 'message', + component: Message, + } + ] + }, + ] +}) diff --git a/20_脚手架/vue_code/src/pages/Home.vue b/20_脚手架/vue_code/src/pages/Home.vue index 695efa3..f40e1c1 100644 --- a/20_脚手架/vue_code/src/pages/Home.vue +++ b/20_脚手架/vue_code/src/pages/Home.vue @@ -1,5 +1,20 @@ diff --git a/20_脚手架/vue_code/src/pages/News.vue b/20_脚手架/vue_code/src/pages/News.vue new file mode 100644 index 0000000..a8d4f7b --- /dev/null +++ b/20_脚手架/vue_code/src/pages/News.vue @@ -0,0 +1,15 @@ + + + diff --git a/20_脚手架/vue_code/src/router/index.js b/20_脚手架/vue_code/src/router/index.js index 55c985e..841b7b5 100644 --- a/20_脚手架/vue_code/src/router/index.js +++ b/20_脚手架/vue_code/src/router/index.js @@ -3,6 +3,8 @@ import VueRouter from "vue-router"; // 引入组件 import About from "@/pages/About.vue" import Home from "@/pages/Home.vue" +import News from "@/pages/News.vue" +import Message from "@/pages/Message.vue"; // 创建一个路由器 export default new VueRouter({ @@ -13,7 +15,17 @@ export default new VueRouter({ }, { path: '/home', - component: Home + component: Home, + children: [ + { + path: 'news', + component: News, + }, + { + path: 'message', + component: Message, + } + ] }, ] })