组件内部守卫
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../js/vue.js"></script>
<script src="../js/vue-router.js"></script>
</head>
<body>
<div id="app">
<!-- 4.路由的使用 -->
<router-link to="/user/1001">组件一</router-link>
<router-link to="/b">组件二</router-link>
<!-- 为组件加载提供容器/窗口 -->
<!-- 实现了组件之间的动态加载 -->
<router-view></router-view>
</div>
<script>
// 1.注册组件
let com1 = {
data() {
return {
id: null
}
},
tem