<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
</div>
<script src="./node_modules/vue/dist/vue.js"></script>
<script src="./node_modules/vue-router/dist/vue-router.js"></script>
<script>
// var router = []
var Login = {
template: '<div>登录页面</div>'
};
var Register = {
template: '<div>注册页面</div>'
};
var router = new VueRouter({
routes: [
{
path: '/login',
name: 'login',
component: Login
},
{
path: '/register',
name: 'register',
component: Register
}
]
});
var App = {
template: `
<div>
<router-link :to="{name:'login'}">登录</router-link>
<router-link :to="{name:'register'}">注册</router-link>
<router-view></router-view>
</div>
`
};
new Vue({
el: '#app',
components: {
App
},
template: `
<App />
`,
router
});
</script>
</body>
</html>
?
|