1.vue中全局注冊組件:https://blog.csdn.net/qq_34089503/article/details/81329405
2.vue中全局定義變量:https://blog.csdn.net/qq_30669833/article/details/81706217
3.vue中路由跳轉(zhuǎn)傳參的方式:
1.路徑:http://localhost:8081/#/test?name=1
<router-link :to="{path:'/test',query: {name: id}}">跳轉(zhuǎn)</router-link>(id是參數(shù))
使用:this.$route.query.name
2.路徑:http://localhost:8081/#/test/1
<router-link :to="'/test/'+id">跳轉(zhuǎn)</router-link>(id是參數(shù))? ?
路由:
使用:this.$route.params.id(這個id給上圖路由的配置有關(guān));
3.在方法中跳轉(zhuǎn)界面并傳參硼瓣,兩種方式:params 與 query
this.$router.push({path:'/order',query:{ id:'2'}});? 接收參數(shù):this.$route.query.id
this.$router.push({name:'order',params:{ id:'6'}});? ?接收參數(shù):?this.$route.params.id
1刺啦、用法上的
剛才已經(jīng)說了,query要用path來引入伏恐,params要用name來引入孩哑,接收參數(shù)都是類似的,分別是this.$route.query.name和this.$route.params.name翠桦。
注意接收參數(shù)的時候横蜒,已經(jīng)是$route而不是$router了哦!销凑!
2丛晌、展示上的
query更加類似于我們ajax中g(shù)et傳參,params則類似于post闻鉴,說的再簡單一點茵乱,前者在瀏覽器地址欄中顯示參數(shù),后者則不顯示
4.父子組件之間的通訊:
父向子傳參:
子組件里面:
? ? ? <div>{{msgfromfa}}</div>
? ? ? ?定義一個自定義屬性:props:['msgfromfa']
父組件里面:
1. 首先引入 import componentA?from?'@/components/componentA'
2.注冊子組件? ?components: {??componentA? }
3.引用?<component-a msgfromfa="(Just Say U Love Me)"></component-a>
子組件向父組件傳參:
1.在子組件里面? this.$emit('say',this.msg) 第一個參數(shù)是自定義的事件孟岛,第二個參數(shù)是要傳遞的參數(shù)
2.在父組件里面??<component-a @say=“fun”></component-a>
fun(msg){
console.log(msg,"msg就是子組件傳遞過來的參數(shù)")
}
5.vue里面動態(tài)的更改title:
index.js里面的meta里面配置每個頁面的title:
main.js里面:
router.beforeEach((to, from, next) => {
? ? if (to.meta.title) {
? ? ? ? document.title = to.meta.title
? ? }
? ? next()
})
6.vue里面路由登錄攔截:https://www.cnblogs.com/beileixinqing/p/7729780.html
7.vue里面解決跨域問題:https://www.cnblogs.com/wangqiao170/p/9288160.html
8.路由配置:
9.路由激活狀態(tài)的樣式:
10.vue中滑動導(dǎo)航插件:https://www.imooc.com/article/23768?block_id=tuijian_wz