我有这个vue js脚本
const NotfoundComponent = {
template: '<h1>Not found</h1>'
};
const HomeComponent = {
template: '<h1>Home</h1>'
};
const AboutComponent = {
template: '<h1>About</h1>'
};
const routes = [
{
path: '/',
component: HomeComponent
},
{
path: '/about',
component: AboutComponent
},
{
path: '*',
component: NotfoundComponent
}
];
const router = new VueRouter({
mode: 'history',
routes
});
new Vue({
el: '#app',
router
});
使用vue-router。我在一个spring mvc app里面的jsp页面里运行vue js。我想正常加载jsp页面由jetty服务,只使用vue js路由器在页面内的组件之间导航。
我有路由器设置并在页面内工作,但是在链接点击,我不想要任何这个vue js链接
<div id="app">
<router-link to="/">home</router-link>
<router-link to="/about">about</router-link>
<router-link to="/something">no route</router-link>
<router-view></router-view>
</div>
修改当前地址栏或添加任何新地址栏。
可以使用vue js吗?
答案 0 :(得分:3)
你想要'abstract
' mode。
const router = new VueRouter({
mode: 'abstract',
routes
});
这需要您推送初始网址:
// you main Vue instance
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
mounted() {
this.$router.replace('/') // added this
}
})
答案 1 :(得分:2)
请检查以下链接,您想使用摘要
https://jsfiddle.net/qpnaokhf/
const router = new VueRouter({
routes,
mode: 'abstract'
})