摘要: views/cityDetail.vue: <template> <div class="city-detail">{{$route.params.id}}</div> </template> <style> .city-detail{ height: 1500px; line-height: 50 阅读全文
posted @ 2021-08-06 22:08 吴小明- 阅读(402) 评论(0) 推荐(0) 编辑
摘要: 给当前路由加上active类名高亮显示: <template> <div id="app"> <router-link to='/' active-class="active">首页</router-link> | <router-link :to="{name:'about'}" active-c 阅读全文
posted @ 2021-08-06 21:08 吴小明- 阅读(2059) 评论(1) 推荐(1) 编辑
摘要: redirect和alias都是可以将一个地址匹配到想要去到的路由 redirect: { path: '/a', redirect: '/about' } 如果访问 /a 会跳转到 /about alias: { path: '/about', name: 'about', component: 阅读全文
posted @ 2021-08-06 20:30 吴小明- 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 命名路由: { path: '/about', name: 'about', component: About } 作用: 1、路由跳转 this.$router.push({ name: 'about' }) 2、路由重定向 { path: '/a', redirect: { // path: ' 阅读全文
posted @ 2021-08-06 20:16 吴小明- 阅读(976) 评论(0) 推荐(0) 编辑
摘要: 使用动态路由: views/Home.vue: <template> <div>Home</div> </template> views/User.js: <template> <div> 当前用户id:{{id}} </div> </template> <script> export defaul 阅读全文
posted @ 2021-08-06 19:35 吴小明- 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Father.vue: <script> import Child from './Child' export default { beforeCreate() { console.log('父组件 beforeCreate') }, created() { console.log('父组件 cre 阅读全文
posted @ 2021-08-06 19:01 吴小明- 阅读(1767) 评论(0) 推荐(2) 编辑
摘要: <body> <div id="app"> <p>{{message}}</p> </div> <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.js"></script> <script> new Vue({ el: '#a 阅读全文
posted @ 2021-08-06 17:28 吴小明- 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 自定义一个TabBar组件: <template> <div class="tab-bar"> <div v-for="(item,index) in tabList" :key="index" :class="['common',{active:currentIndex index}]" @cli 阅读全文
posted @ 2021-08-06 16:55 吴小明- 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 异步组件和路由懒加载的原理比较像,路由懒加载是将router.js中的路由通过懒加载的方式引入进来从而提升性能,异步组件是那些没有当做路由去使用的组件,如果需要提升这部分组件加载的性能,需要将它的引入方式由同步改为异步。 1、定义一个List.vue: <template> <div>这是一个列表的 阅读全文
posted @ 2021-08-06 16:11 吴小明- 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 1、安装: npm install vue-awesome-swiper@3 --save-dev 我的版本是: "vue": "^2.6.11" "vue-awesome-swiper": "^3.1.3" 2、使用: <template> <div class="recommendPage"> 阅读全文
posted @ 2021-08-06 14:47 吴小明- 阅读(1553) 评论(0) 推荐(0) 编辑