亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

[VUE CLI3] 多頁面devServer 跳轉 返回html錯誤問題

[VUE CLI3] 多頁面devServer 跳轉 返回html錯誤問題

翻閱古今 2019-03-21 22:15:13
問題描述最近嘗試把項目腳手架從vue-cli2 webpack2 更新到vue/cli 3 webpack4由于之前項目是多頁面,在用腳手架生成了項目目錄之后, 在vue-cli-service serve開發環境時發現了一些問題。工程里有兩個頁面index和login, 也配了兩個入口。但在默認頁面中路由跳轉都正常,但我點擊按鈕 通過window.location.href = '/login' 訪問另一個頁面login時,返回的資源依然是index.html和index.js只有通過更改url訪問 localhost:3007/login.html時,url會變成localhost: 3007/login/.html這時候才會返回login.html和login.jsPS:通過 build打包之后訪問后臺(nodejs)訪問一切都正常。項目目錄問題出現的環境背景及自己嘗試過哪些方法相關代碼vue.config.jsmodule.exports = {  devServer: {    port: 3007,    host: 'localhost',    open: true,    proxy: {      '/api': {        target: 'localhost: 3333',        changeOrigin: true,        // ws: true,        pathRewrite: {          '^/api': '/api'        }      }    }  },  chainWebpack: config => {  },  pages: {    index: {      // page 的入口      entry: 'src/main.js',      // 模板來源      template: 'public/index.html',      // 在 dist/index.html 的輸出      filename: 'index.html',      // 當使用 title 選項時,      // template 中的 title 標簽需要是 <title><%= htmlWebpackPlugin.options.title %></title>      title: 'Index Page',      // 在這個頁面中包含的塊,默認情況下會包含      // 提取出來的通用 chunk 和 vendor chunk。      chunks: ['chunk-vendors', 'chunk-common', 'index']    },    login: {      entry: 'src/login.js',      template: 'public/login.html',      filename: 'login.html',      title: '登陸',      chunks: ['chunk-vendors', 'chunk-common', 'login']    },    // 當使用只有入口的字符串格式時,    // 模板會被推導為 `public/subpage.html`    // 并且如果找不到的話,就回退到 `public/index.html`。    // 輸出文件名會被推導為 `subpage.html`。    // subpage: 'src/subpage/main.js'  },}你期待的結果是什么?實際看到的錯誤信息又是什么?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 1194 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號