diff --git a/学习VUE/hello_vue3/src/App.vue b/学习VUE/hello_vue3/src/App.vue index 78d2f0a..2131d76 100644 --- a/学习VUE/hello_vue3/src/App.vue +++ b/学习VUE/hello_vue3/src/App.vue @@ -1,75 +1,16 @@ diff --git a/学习VUE/hello_vue3/src/components/Count.vue b/学习VUE/hello_vue3/src/components/Count.vue new file mode 100644 index 0000000..3343508 --- /dev/null +++ b/学习VUE/hello_vue3/src/components/Count.vue @@ -0,0 +1,38 @@ + + + + + \ No newline at end of file diff --git a/学习VUE/hello_vue3/src/components/LoveTalk.vue b/学习VUE/hello_vue3/src/components/LoveTalk.vue new file mode 100644 index 0000000..9fa0ce6 --- /dev/null +++ b/学习VUE/hello_vue3/src/components/LoveTalk.vue @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/学习VUE/hello_vue3/src/main.ts b/学习VUE/hello_vue3/src/main.ts index a4c897d..907e1eb 100644 --- a/学习VUE/hello_vue3/src/main.ts +++ b/学习VUE/hello_vue3/src/main.ts @@ -4,9 +4,15 @@ import { createApp } from 'vue' import App from './App.vue' // 引入路由器 import router from "./router"; +// 第一步:引入pinia +import {createPinia} from 'pinia' +// 第二步:创建pinia +const pinia = createPinia() //创建一个app const app = createApp(App) //使用路由器 app.use(router) +// 第三步:安装pinia +app.use(pinia) //挂载整个应用到app容器中 app.mount('#app') diff --git a/学习VUE/hello_vue3/src/pages/News.vue b/学习VUE/hello_vue3/src/pages/News.vue index 309c5db..f5a36ca 100644 --- a/学习VUE/hello_vue3/src/pages/News.vue +++ b/学习VUE/hello_vue3/src/pages/News.vue @@ -2,7 +2,7 @@
@@ -13,8 +13,8 @@ diff --git a/学习VUE/hello_vue3/笔记/路由重定向.ts b/学习VUE/hello_vue3/笔记/路由重定向.ts new file mode 100644 index 0000000..e6ada50 --- /dev/null +++ b/学习VUE/hello_vue3/笔记/路由重定向.ts @@ -0,0 +1,42 @@ +import {createRouter, createWebHistory} from 'vue-router' + +import Home from '@/pages/Home.vue' +import News from '@/pages/News.vue' +import About from '@/pages/About.vue' +import Details from '@/pages/Details.vue' + +//创建路由器 +const router = createRouter({ + history: createWebHistory(), //路由器的工作模式 + routes: [ + { + name: 'home', + path: '/', + component: Home + }, + { + name: 'news', + path: '/news', + component: News, + children: [ + { + name: 'news-details', + path: 'details', // 注意:子路由的 path 不需要以 "/" 开头 + component: Details + } + ] + }, + { + name: 'about', + path: '/about', + component: About + }, + { + path: '/news', + redirect: '/about', // 重定向 + } + ] +}) + +// 暴露出去 router +export default router \ No newline at end of file