·需要通过 Vue Router实例的mode选项来设置,这样URL会更加美观,但同样需要后端支持避免问题。
<div>这是首页功能</div>
};
var User = {
template: <div>这是用户功能</div>
};
var Category = {
template: <div>这是分类功能</div>
};
var router = new VueRouter({
mode: ‘history’,
routes: [
{ path: ‘/‘, component: Index },
{ path: ‘/user’, component: User },
{ path: ‘/category’, component: Category },
]
});
var vm = new Vue({
el: ‘#app’,
router
})
</script>
</body>
</html>