国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

VUE : vue-cli中去掉路由中的井號#操作

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

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

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

VUE : vue-cli中去掉路由中的井號#操作

VUE : vue-cli中去掉路由中的井號#操作

補充知識:vue 打包部署去掉#注意事項

示例基于vue cli2.0腳手架生成的項目

1.vue項目中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/’, // 這個地方使用絕對路徑 很重要! /** * 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/’, // 這個配置也很重要,否則會出現(xiàn)頁面空白情況 scrollBehavior: () => ({ y: 0 }), routes: [ { path: ’/facebook’, name: ’Facebook’, component: Facebook }, { path: ’/google’, name: ’Google’, component: Google } ]})

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

server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #打包后的項目目錄,一定記住這個地方帶有項目名稱 root /Users/qiilee/Desktop/vue/dist; index index.html; location /dist {#這個地方?jīng)]有項目名稱,因為請求的時候如果請求:http://localhost:8080/dist ,nginx會查找/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ā)布二級一下的路由會出現(xiàn)js加載,但是也沒空白的情況 location @router {rewrite ^.*$ /index.html last; } }

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

標簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 免费黄色网址在线播放 | 在线高清一级欧美精品 | 国产手机免费视频 | 国产一区影视 | 亚洲国产欧美在线成人aaaa | 国产精品久久久免费视频 | 成人综合网址 | 亚洲欧美成人综合 | 91精品国产薄丝高跟在线看 | 国产三级精品三级 | 欧美孕妇性xxxⅹ精品hd | 在线观看国产一区二区三区 | 国产日产高清欧美一区二区三区 | 成人午夜网 | 久久精品视频免费在线观看 | 久久永久免费 | 欧美日韩高清在线观看一区二区 | 欧美成人性毛片免费版 | 性8sex亚洲区入口 | 欧美午夜网 | 欧美国产日本 | 99爱视频99爱在线观看免费 | 热99re久久精品这里都是免费 | 真实的国产乱xxxx | 亚洲美女黄视频 | 亚洲va久久久噜噜噜久久狠狠 | 欧美性精品videofree | 欧美成人一区二区三区在线视频 | 国产欧美日韩精品在线 | 国产成人一级片 | 亚洲精品免费网站 | 国产精品视频视频久久 | 一区二区三区在线看 | 欧美va在线播放免费观看 | 成年人免费在线观看网站 | 亚洲精品成人一区 | 亚洲免费一级片 | 久草在线资源网站 | 成人69视频在线观看免费 | 久久香蕉国产精品一区二区三 | 精品91一区二区三区 |