Skip to content

Instantly share code, notes, and snippets.

@Panigale
Last active August 27, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Panigale/2cda8d487a795149e708f606fa0ad87f to your computer and use it in GitHub Desktop.
Save Panigale/2cda8d487a795149e708f606fa0ad87f to your computer and use it in GitHub Desktop.
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.0.0-rc.3/vue-router.js"></script>
<div id="app">
<h1>Hello App!</h1>
<ul>
<li>
<router-link to="/foo">foo</router-link>
</li>
<li>
<router-link to="/bar">bar</router-link>
</li>
</ul>
<router-view></router-view>
</div>
<script>
//定義foo路徑元件
var Foo = Vue.extend({
template: '<p>This is foo!</p>'
})
//定義bar路徑元件
var Bar = Vue.extend({
template: '<p>This is bar!</p>'
})
var router = new VueRouter({
mode: 'history',
routes: [
{ path: '/foo' ,component:Foo},
{ path: '/bar' ,component:Bar}
]
});
new Vue({
router,
el:'#app',
}).$mount('#app');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment