<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>演示Vue路由</title>
</head>
<body>
<div id="app">
<div>
<router-link to="/">首页</router-link>
<router-link to="/about">关于我们</router-link>
</div>
<div>
<router-view></router-view>
</div>
</div>
<script src="../js/vue.js"></script>
<script src="../js/vue-router.js"></script>
<script>
let routesObj = [
{
path:'/',
component:{
template:'<div><h2>首页</h2></div>'
}
},
{
path: '/about',
component: {
template: '<div><h2>关于我们</h2></div>'
}
}
];
let routerK = new VueRouter({
routes:routesObj
});
let vm = new Vue({
el:'#app',
router:routerK
});
</script>
</body>
</html>
vue-例9-1演示Vue路由.html
最新推荐文章于 2023-07-18 22:55:36 发布