1. 程式人生 > >vue巢狀路由-query傳遞引數

vue巢狀路由-query傳遞引數

home.vue 通過query來傳遞num引數為1,相當與在 url 地址後面拼接引數
<template>
	<div>
		<h3>首頁</h3>
		<router-link :to="{ path:'/home/game', query: { num:  1} }">
			<button>顯示<tton>
		</router-link>

		<router-view></router-view>
	</div>
</template>
game.vue 子路由中通過 this.$route.query.num 來顯示傳遞過來的引數
	<template>
		<h3>王者榮耀{{ this.$route.query.num }}</h3>
	</template>

執行後的結果,傳遞的引數在位址列中有顯示