一跨跨、query和params傳參區(qū)別
query相當(dāng)于get請(qǐng)求,頁(yè)面跳轉(zhuǎn)的時(shí)候潮峦,可以在地址欄看到請(qǐng)求參數(shù)
而params相當(dāng)于post請(qǐng)求,參數(shù)不會(huì)再地址欄中顯示
傳參:
二、router/route的區(qū)別
打印this.$router :(路由的一些功能E芎肌C薄!5铝隆5鳌!U觥@⑶!M终怠)
this.$router.push
this.$router.addRouter...
打印this.$route:(當(dāng)前路由的一些信息/屬性W檠狻!L图铡T愫臁!N谝丁E璩ァ!W荚 J屡ぁ)
this.$route.query...
this.$route.params
路由的使用步驟:
- 引入包 npm install vue-router -S 后
main.js中引入import VueRouter from 'vue-router'- 創(chuàng)建實(shí)例化VueRouter對(duì)象
- 匹配路由規(guī)則
const router = new VueRouter({
routes // 路由列表 eg: [{ path: '/foo', component: Foo }]
});- 掛載new Vue()實(shí)例化對(duì)象中/Vue.use(VueRouter)
附加router-view內(nèi)容
怎么刷新router-view中的內(nèi)容
<router-view :key="activeDate" />
activeDate: 1
事件中 this.activeDate = new Date().getTime()
緩存router-view中的內(nèi)容
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>