亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

VUE : vue-cli中去掉路由中的井號(hào)#操作

瀏覽:94日期:2022-11-28 18:20:13

vue-cli項(xiàng)目中,如果想去掉url地址欄中的“#”我們可以用路由的 history 模式,這種模式充分利用 history.pushState API 來完成 URL 跳轉(zhuǎn)而無須重新加載頁面。

只需要在路由表中,加入一行代碼即可。

VUE : vue-cli中去掉路由中的井號(hào)#操作

VUE : vue-cli中去掉路由中的井號(hào)#操作

補(bǔ)充知識(shí):vue 打包部署去掉#注意事項(xiàng)

示例基于vue cli2.0腳手架生成的項(xiàng)目

1.vue項(xiàng)目中config文件下index.js中打包配置:

build: { // Template for index.html index: path.resolve(__dirname, ’../dist/index.html’), // Paths assetsRoot: path.resolve(__dirname, ’../dist’), assetsSubDirectory: ’static’, assetsPublicPath: ’/dist/’, // 這個(gè)地方使用絕對(duì)路徑 很重要! /** * Source Maps */ productionSourceMap: true, // https://webpack.js.org/configuration/devtool/#production devtool: ’#source-map’, // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. // Before setting to `true`, make sure to: // npm install --save-dev compression-webpack-plugin productionGzip: false, productionGzipExtensions: [’js’, ’css’], // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off bundleAnalyzerReport: process.env.npm_config_report}

2.路由配置:router文件夾下index.js:

export default new Router({ mode: ’history’, // 去掉#,需要路由模式改為history base: ’/dist/’, // 這個(gè)配置也很重要,否則會(huì)出現(xiàn)頁面空白情況 scrollBehavior: () => ({ y: 0 }), routes: [ { path: ’/facebook’, name: ’Facebook’, component: Facebook }, { path: ’/google’, name: ’Google’, component: Google } ]})

3.剩下的不懂 就要找你得運(yùn)維或者后端開發(fā)小伙伴了,nginx配置:

server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #打包后的項(xiàng)目目錄,一定記住這個(gè)地方帶有項(xiàng)目名稱 root /Users/qiilee/Desktop/vue/dist; index index.html; location /dist {#這個(gè)地方?jīng)]有項(xiàng)目名稱,因?yàn)檎?qǐng)求的時(shí)候如果請(qǐng)求:http://localhost:8080/dist ,nginx會(huì)查找/Users/qiilee/Desktop/vue/dist/目錄下的數(shù)據(jù)root /Users/qiilee/Desktop/vue;try_files $uri $uri/ @router;index index.html; } //try_files $uri $uri/ @router;和下邊部分很重要,沒有這部分發(fā)布二級(jí)一下的路由會(huì)出現(xiàn)js加載,但是也沒空白的情況 location @router {rewrite ^.*$ /index.html last; } }

以上這篇VUE : vue-cli中去掉路由中的井號(hào)#操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 国产免费无遮挡精品视频 | 国内精品91最新在线观看 | 热综合一本伊人久久精品 | 国产区综合 | 精品黄色片 | 久久久久国产视频 | 日韩亚洲国产欧美精品 | 成人a毛片视频免费看 | 日韩免费一级毛片欧美一级日韩片 | 国产精品第三页 | 亚洲综合视频在线观看 | 亚洲人成网站观看在线播放 | 精品国产自在现线看久久 | 久久综合精品国产一区二区三区无 | 成人在线免费观看视频 | 香蕉视频免费在线播放 | 日本乱人伦毛片 | 青草视频在线 | 久久激情免费视频 | 91久久九九精品国产综合 | 成人久久久久 | 91蜜桃传媒一二三区 | 欧美性生活视频 | 亚洲第一黄色 | 亚洲天天综合 | 国产精品免费看 | 妖精视频在线观看网站 | 国产精品一级毛片不收费 | 国产 另类 在线 欧美日韩 | 欧美精品一区在线看 | 色综合综合色综合色综合 | 国产热视频 | 国产美女主播一级成人毛片 | 国内免费在线视频 | 在线播放国产区 | 欧美日韩国产在线人 | 欧美一级视频免费观看 | 久久久久久久久久综合情日本 | 精品国产_亚洲人成在线高清 | 日韩毛片在线免费观看 | 普通话对白国产情侣自啪 |