1.看一下你是不是也是这样的问题
我们的URL的会一直带着有这个#号,那么如何让去除呢?
2.操作步骤
2.1找到你vue项目的src/router
2.2只要在新建Router对象的时候,添加一个属性 mode:'history'
从新编译项目,即可。
这是源码,贴出来大家可以稍加参考
import Vue from 'vue'
import Router from 'vue-router'
import indexPage from '@/page/index/indexPage'
import personPage from '@/page/personpage/PersonPage'
import login from '@/page/login/Login'
import register from '@/page/register/register'
import forgetPassword from '@/page/forgetpassword/ForgetPassword'
import white from '@/page/white/white'
Vue.use(Router)
export default new Router({
//routes里的代码没有太多参考价值,主要是要看 mode:'history' 加的位置
routes: [
{
path: '/',
name: 'indexPage',
component: indexPage
}, {
path: '/personPage',
name: 'personPage',
component: personPage
}, {
path: '/login',
name: '/login',
component: login
}, {
path: '/register',
name: '/register',
component: register
}, {
path: '/forgetPassword',
name: '/forgetPassword',
component: forgetPassword
}, {
path: '/white',
name: '/white',
component: white
}
],
mode:'history'
})
这样 # 号 就没了