注意:项目初始化时不要集成vue-router
cnpm install vue-router --save
在main.js中引入: import VueRouter from 'vue-router' Vue.use(VueRouter)
在main.js中 const router=new VueRouter({ routes:[{ path:"/", name:"HelloWorld", component:HelloWorld
}]
})
在App.vue中:
在main.js中: new Vue({ el: '#app', router, components: { App }, template: '' })
属性:tagpath:"/learn/:id" 访问:{{this.$route.params.id}}
在路由中加children: { path:"/learn/", children:[//二级 { path:"base", component:Base, children:[]//三级 }, { path:"http", component:Http } ], name:"LearnVue", component:LearnVue }
router.push({}) router.replace({}) router.go({})
hello this.$route.push({name:'HelloWorld',params:{id:this.clickparams}}) //注意是route不是router
{//没有路径 path:"*", component:NotFound, }, {//重定向 path:"/", redirect:"/learn" },
在index.js中 linkActiveClass:"active",//模糊匹配 linkExactActiveClass:"currentActive",//精准匹配 在App.vue中css: 点亮图标 /.router-link-active{ color:red; }/ .active{ color:red; } //精准匹配 /.router-link-exact-active{ border:4px solid green; }/
.currentActive{ border:4px solid green; }
https://element.eleme.cn/#/zh-CN
cnpm i element-ui -S
import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);
首先,安装 babel-plugin-component: cnpm install babel-plugin-component -D 更改 .babelrc: { "presets": [["es2015", { "modules": false }]], "plugins": [ [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ] ] } 引入需要应用的部分: import { Button, Select } from 'element-ui'; Vue.use(Button) Vue.use(Select)
https://github.com/surmon-china/vue-awesome-swiper
cnpm install vue-awesome-swiper --save
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper, /* { default global options } */)
使用网络请求组件:axios
https://github.com/vuejs/awesome-vue
安装:cnpm install vue-progressbar 导入: import VueProgressBar from 'vue-progressbar' const options = { color: '#bffaf3', failedColor: '#874b4b', thickness: '5px', transition: { speed: '0.2s', opacity: '0.6s', termination: 300 }, autoRevert: true, location: 'left', inverse: false } Vue.use(VueProgressBar, options) 使用: https://github.com/hilongjw/vue-progressbar