Use the official route plug-ins: Vue-router
1. Import Plug
<script src="https://unpkg.com/[email protected]/dist/vue-router.js"> </script>
2. Set routing object
routes = var [{
path: '/ About' ,
Component: {
Template: '<div> This is the first component </ div>'
}
}
,
{path: '/' , Component: { Template: '<div > second component </ div> '
} } ]
3. Bind to the routing object instance Vue
var vm=new Vue({
el:'#demo',
data:{
},
router:router
})
I found a bug:
After investigation found the cause: Vue-router depends on the Vue plug-in framework, the framework should first import Vue