vue3.0中改变router为hash或者history
前言:在这里我们分析总结下vue2.0和vue3.0改变router为hash或者history 的方法。vue2.0history:const router = new VueRouter({mode: 'history',routes: [...]})hash:const router = new VueRouter({mode: 'hash',//或者把这句话注释,默认就是hashroute
·
前言:
在这里我们分析总结下vue2.0和vue3.0 改变router为hash或者history 的方法。
vue2.0
history:
const router = new VueRouter({
mode: 'history',
routes: [...]
})
hash:
const router = new VueRouter({
mode: 'hash', //或者把这句话注释,默认就是hash
routes: [...]
})
vue3.0
history: 引入-createWebHistory
import { createRouter, createWebHistory} from 'vue-router';
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
});
hash: 引入-createWebHashHistory
import { createRouter, createWebHashHistory } from 'vue-router';
const router = createRouter({
history: createWebHashHistory(),
routes
});
更多推荐
已为社区贡献102条内容
所有评论(0)