vue-动态路由

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>

		<div id="app">
			<p>
				<router-link to="/user/a">/user/foo</router-link>
				<router-link to="/user/b">/user/bar</router-link>
			</p>
			<router-view></router-view>
		</div>
		<script src="https://unpkg.com/vue/dist/vue.js"></script>
		<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
		<script type="text/javascript">
			const User = {
				template: '<div>User {{ $route.params.id }}</div>'
			}
			const router = new VueRouter({
				routes: [
					{ path: '/user/:id', component: User }
				]
			})
			const app = new Vue({ router }).$mount('#app')
		</script>
	</body>

</html>

  

posted @ 2017-08-15 10:30  LWJ_jay  阅读(128)  评论(0编辑  收藏  举报