欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          vue什么時(shí)候會(huì)出現(xiàn)白屏

          vue出現(xiàn)白屏的3種情況:1、把路由模式mode設(shè)置成history了;只需改為hash或者直接刪除模式配置,如果非要用history的話,在服務(wù)端加一個(gè)覆蓋所有情況的候選資源即可。2、打包后的dist目錄下的文件引用路徑不對(duì),會(huì)因找不到文件而報(bào)錯(cuò)導(dǎo)致白屏;修改一下config下面的index.js中bulid模塊導(dǎo)出的路徑即可。3、項(xiàng)目中用了es6語法,但瀏覽器不支持es6。

          vue什么時(shí)候會(huì)出現(xiàn)白屏

          前端(vue)入門到精通課程,老師在線輔導(dǎo):聯(lián)系老師
          Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調(diào)試工具:點(diǎn)擊使用

          本教程操作環(huán)境:windows7系統(tǒng)、vue3版,DELL G3電腦。

          vue出現(xiàn)白屏現(xiàn)象主要幾種原因和解決辦法

          第一種:由于把路由模式mode設(shè)置成history了,默認(rèn)是hash。

          解決方法:改為hash或者直接刪除模式配置,如果非要用的話,在服務(wù)端加一個(gè)覆蓋所有情況的候選資源。

          如果你改成了history模式的話,打開也會(huì)是一片空白。所以改為hash或者直接把模式配置刪除,讓它默認(rèn)的就行 。如果非要使用history模式的話,需要你在服務(wù)端加一個(gè)覆蓋所有的情況的候選資源:如果URL匹配不到任何靜態(tài)資源,則應(yīng)該返回一個(gè)index.html,這個(gè)頁面就是你app依賴頁面。

          第二種:打包后的dist目錄下的文件引用路徑不對(duì),會(huì)因找不到文件而報(bào)錯(cuò)導(dǎo)致白屏。

          解決辦法:修改一下config下面的index.js中bulid模塊導(dǎo)出的路徑。

          因?yàn)閕ndex.html里邊的內(nèi)容都是通過script標(biāo)簽引入的,而你的路徑不對(duì),打開肯定是空白的。先看一下默認(rèn)的路徑。

          build: {     // Template for index.html     index: path.resolve(__dirname, '../dist/index.html'),      // Paths     assetsRoot: path.resolve(__dirname, '../dist'),     assetsSubDirectory: 'static',     assetsPublicPath: './',      /**      * Source Maps      */      productionSourceMap: false,     // 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   }
          登錄后復(fù)制

          assetsPublicPath默認(rèn)的是 ‘/’ 也就是根目錄。而我們的index.html和static在同一級(jí)目錄下面。 所以要改為 ‘./ ’;

          如果還是報(bào)錯(cuò),修改build/webpack.prod.conf.js文件下webpackConfig,在output屬性中添加 publicPath:"./",重新運(yùn)行打包。

          output: {     path: config.build.assetsRoot,     filename: utils.assetsPath('js/[name].[chunkhash].js'),     chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')   }
          登錄后復(fù)制

          第三種:在項(xiàng)目中使用了es6的語法,一些瀏覽器不支持es6,造成編譯錯(cuò)誤不能解析而造成白屏

          解決方法:安裝Babel ,Babel 會(huì)把這些新語法轉(zhuǎn)譯成較低版本的代碼。

          npm install --save-dev @babel/core @babel/cli @babel/preset-env
          登錄后復(fù)制

          【學(xué)習(xí)視頻分享:vue視頻教程、web前端視頻】

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)