diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-15.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-15.md" new file mode 100644 index 0000000000000000000000000000000000000000..2003617c0eedf56fb3a7e649a55d4613776968c9 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-15.md" @@ -0,0 +1,35 @@ +## 今日笔记 + +### vue 路由的使用。 + +### vue add -h (查看目录底下的文件夹) + ++ yarn add vuex(文件夹) -D (下载到开发模式下的)。 ++ +1. 创建组件 + ++ 首先引入 vue.js 和 vue-router.js; ++ ++ ++ ++ ++ +2. 创建Router ++ ++var router=new VueRouter() ++或者是使用全局 Vue.use(VueRouter) ++ +3. 映射路由 ++ +``` ++router.map({ ++ '/home':{component:Home}, ++ '/about':{component:About} ++}) ++ +``` ++ +4. 使用 v-link 指令 ++ +5. 使用 标签 + diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-16.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-16.md" new file mode 100644 index 0000000000000000000000000000000000000000..cd79f1db08fc8a37302dbe36d605ed503be47586 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-16.md" @@ -0,0 +1,167 @@ +# 今日笔记 + +### 动态路由的匹配和 + +#### 路由的使用步骤。 + +1. 导入Vue和VueRouter,要调用Vue.use(VueRouter)全局使用。 ++ ++ improt Vue from 'vue ++ ++ improt Router from 'vue-router' ++ ++ Vue.use(Router) ++ +2. 导入相应的组件 ++ +3. 定义路由 ++ +``` ++const routes = [ ++ {path:'/foo',component:Foo}, ++ {path:'bar',component:Bar} ++] ++ +``` ++ +4. 创建router 实例,传入定义的路径作为参数 + +``` ++const router=new VueRouter({ ++ routes // routes 就相当于我们定义的路由 ++}) ++ +``` + +5. 注入路由 + ++``` ++const aap = new Vue({ ++ router // 这是我们创建的实例 ++}) ++ +``` ++ +1. 路由器 可以在任意组件中访问 ++this.$router ++ ++2. :访问当前路由 ++this.$route ++ ++3. 这两个属性其实也都是已经放在里面 this(当前组件的data返回对象中)。 ++ ++ ++main.js ++//引入需要的路由 或者依赖等 ++import Vue from 'vue' ++import App from './App.vue' ++import VueRouter from 'vue-router' ++import Big from './components/Big' ++import Day from './components/Day' ++import P404(可定义名称) from './components/404' ++ ++ ++Vue.use(VueRouter)//使用VueRouter ++ ++Vue.config.productionTip = false ++//实例化router 引入定义的组件和路径 ++let router =new VueRouter({ ++ mode:'history', ++ routes:[ ++ { ++ path:'/big/:id', ++ component:Big, ++ children:[ ++ { ++ path:'', ++ component:Day ++ } ++ ] ++ },{ ++ //查找路径 路径优先级由上至下 没找到的路径都会跳转到组件404路由页面 ++ path:'*', ++ component:P404 ++ } ++ ++ ++ ] ++}) ++ ++ ++new Vue({ ++ router, ++ render: h => h(App), ++}).$mount('#app') ++ ++Big.vue ++ ++ + + + + + +Day.vue + + + + + +404.vue + + +``` \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-18.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-18.md" new file mode 100644 index 0000000000000000000000000000000000000000..498060fa58181c43cafe04249efe23e5e8ac7f11 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-18.md" @@ -0,0 +1,39 @@ +## 今日笔记 + + + +## 文本字符串路径 +router.push('home') + +# 对象 +router.push({ path: 'home' }) + +# 命名路由 要params可以使用,path不能写死,正确path /user/:userId +router.push({ name: 'user', params: { userId: '123' } }) + +# 带query查询,结果是/register?plan=private +router.push({ path: 'register', query: { plan: 'private' } }) +# 编程式导航 +定义路由 +在app页面写如导航 +``` +mounted: function () { + setTimeout(() => { + this.$router.push({ + path: "login", + query: { + name: "登录", + }, + }); + }, 2000); + }, +``` +`query` 和 `params`都是给导航页面传参数 不同的是query传的参数可以在搜素栏中显示出来 + +当在导航的页面是原来的页面时会出现导航冗余的情况,解决方法为在路由页面中, `Vue.use(VueRouter);`后写入 +``` +const or=VueRouter.prototype.push; +VueRouter.prototype.push=function push(location){ + return or.call(this,location).catch(err=>err) +} +``` \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-19.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-19.md" new file mode 100644 index 0000000000000000000000000000000000000000..492d5a4019a7ad99119b98c3cf112a0a7faf1e4b --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-19.md" @@ -0,0 +1,18 @@ +## 今日笔记 + +# 命名路由 ++有时候,通过一个名称来标识一个路由显得更方便一些,特别是在链接一个路由,或者是+执行一些跳转的时候。 ++ ++在定义路由后,添加一个name键值对,给路由命名,命名的使用方法为 +``` ++ user +``` +## 命名视图 + +``` ++ ++ ++ ++``` ++ ++ router-view没有name时将default作为它的name。 \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-5-28 8-40-33.JPG" "b/\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 8-40-33.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-5-28 8-40-33.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 8-40-33.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-21-47.JPG" "b/\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-21-47.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-21-47.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-21-47.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-35-32.JPG" "b/\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-35-32.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-35-32.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-35-32.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-40-17.JPG" "b/\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-40-17.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-40-17.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-40-17.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-40-30.JPG" "b/\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-40-30.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-5-28 9-40-30.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/5.28/2021-5-28 9-40-30.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-1 8-43-7.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.1/2021-6-1 8-43-7.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-1 8-43-7.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.1/2021-6-1 8-43-7.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 14-38-12.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 14-38-12.JPG" new file mode 100644 index 0000000000000000000000000000000000000000..5307493e6142255a7300b33d372309910a7528a3 Binary files /dev/null and "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 14-38-12.JPG" differ diff --git "a/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-2.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-2.JPG" new file mode 100644 index 0000000000000000000000000000000000000000..17ce1e830444d9958131fe7e4e12c141d266e007 Binary files /dev/null and "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-2.JPG" differ diff --git "a/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-7.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-7.JPG" new file mode 100644 index 0000000000000000000000000000000000000000..55432e2254d568af6cef3a39262878a1341fb600 Binary files /dev/null and "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-13-7.JPG" differ diff --git "a/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-36-39.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-36-39.JPG" new file mode 100644 index 0000000000000000000000000000000000000000..f57a3dada563b7864f536654acca2b526d048af6 Binary files /dev/null and "b/\351\273\204\345\213\207\350\276\211/img/6.19/2021-6-19 15-36-39.JPG" differ diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-2 14-39-43.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 14-39-43.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-2 14-39-43.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 14-39-43.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-31-13.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-31-13.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-31-13.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-31-13.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-31-17.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-31-17.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-31-17.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-31-17.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-32-28.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-32-28.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-32-28.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-32-28.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-35-32.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-35-32.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-2 15-35-32.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.2/2021-6-2 15-35-32.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-4 9-15-47.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.4/2021-6-4 9-15-47.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-4 9-15-47.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.4/2021-6-4 9-15-47.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-4 9-21-34.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.4/2021-6-4 9-21-34.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-4 9-21-34.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.4/2021-6-4 9-21-34.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-5 15-24-59.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.5/2021-6-5 15-24-59.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-5 15-24-59.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.5/2021-6-5 15-24-59.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/2021-6-5 15-9-17.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.5/2021-6-5 15-9-17.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/2021-6-5 15-9-17.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.5/2021-6-5 15-9-17.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-25-17.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-25-17.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-25-17.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-25-17.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-31-24.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-31-24.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-31-24.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-31-24.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-32-26.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-32-26.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 10-32-26.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 10-32-26.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 8-45-43.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 8-45-43.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 8-45-43.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 8-45-43.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-22-52.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-22-52.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-22-52.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-22-52.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-25-56.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-25-56.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-25-56.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-25-56.JPG" diff --git "a/\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-36-44.JPG" "b/\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-36-44.JPG" similarity index 100% rename from "\351\273\204\345\213\207\350\276\211/img/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/2021-6-8 9-36-44.JPG" rename to "\351\273\204\345\213\207\350\276\211/img/6.8/2021-6-8 9-36-44.JPG"