iT邦幫忙

0

vue3 項目打包?? npm run build如何運行?

  • 分享至 

  • xImage

vue3 項目打包?? npm run build如何運行?

npm create vite@latest
cd alex
npm install
npm run dev
npm run dev正常有出現Vite + Vue頁面

npm add -d sass

},
"dependencies": {
"sass": "^1.59.2",
"vue": "^3.2.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"vite": "^4.1.0"
}

Node.js v18.15.0.
win10作業系統

npm run build

有dist資料夾
有assets
資料夾內
index-XXXX.js
index-XXXX.css

index.html
依說明有修改相對路徑

script type="module" crossorigin src="assets/index-4185dbbb.js"></script
link rel="stylesheet" href="assets/index-c82943c1.css"

本機測試打開index.html頁面一片空白,並沒出現Vite + Vue頁面,修改相對路徑,測試css有作用,在本機appserv伺服器,也是一片空白,CSS測試有作用.不明白怎樣才有作用,顥示Vite + Vue

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
greenriver
iT邦研究生 5 級 ‧ 2023-03-14 08:26:04
最佳解答

如果是用 createWebHistory ,
那 router/index.js 也要修改。
如下,要修改theFolder的位置。

const theFolder = '/myWebSite/'
const router = createRouter({
  // 根據指定架站位置的資料夾
  history: createWebHistory(theFolder),
  routes
})
ppp896 iT邦新手 4 級 ‧ 2023-03-14 10:21:24 檢舉

感恩,謝謝.研究中.....

我要發表回答

立即登入回答