<div id="app">
<router-view></router-view>
</div>
<template id="a">
<div @click="link">hello</div>
</template>
<template id="b">
<div>world</div>
</template>
const Home = Vue.extend({ template: "#a", data: function() { return {} }, methods: { link: function () { this.$router.push('/b') } } }) const B = Vue.extend({ template: "#b" }) // 路由 const routes = [ {path:'/',component:Home}, {path:'/b',component:B} ]; const router = new VueRouter({ routes }) new Vue({ el:"#app", router })
本文介绍了一个使用Vue.js的简单示例,包括组件间的导航与切换。通过定义不同的模板和组件,演示了如何利用Vue-router进行页面跳转。
1673

被折叠的 条评论
为什么被折叠?



