首页 新闻 会员 周边 捐助

Vue 3 加vite 加ts 中使用img src 路径不对,为什么会包错

0
[已关闭问题] 关闭于 2021-07-22 17:52

npm run dev
可以运行起来,
但是运行
npm run build 后就提示
Could not resolve './assets/img/home/preview/01.jpg' from src\components\DemosSection.vue

这个图片路径是不存在的,我没有这个图片,
为什么不可以打包啊?坑,巨坑

使用的是vs code
<template>
<header class="bg-light shadow-sm navbar-sticky">
<div class="navbar navbar-expand-lg navbar-light">
<div class="container">
<a class="navbar-brand d-none d-sm-block me-4 order-lg-1" href="index.html">
<img src="../public/img/logo-dark.png" width="142" alt="Cartzilla" />
</a>

具体错误内容: <img src="../public/img/logo-dark.png" width="142" alt="Cartzilla" />
所有错误内容:
npm run build

@0.0.0 build D:\CodeDemo\VuejsApp\blog
vue-tsc --noEmit && vite build

vite v2.4.2 building for production...
✓ 10 modules transformed.
Could not resolve './assets/img/home/preview/01.jpg' from src\components\DemosSection.vue
error during build:
Error: Could not resolve './assets/img/home/preview/01.jpg' from src\components\DemosSection.vue
at error (D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:151:30)
at ModuleLoader.handleResolveId (D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:19797:24)
at D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:19746:22
at async Promise.all (index 2)
at async ModuleLoader.fetchStaticDependencies (D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:19744:34)
at async Promise.all (index 0)
at async ModuleLoader.fetchModule (D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:19720:9)
at async Promise.all (index 4)
at async ModuleLoader.fetchStaticDependencies (D:\CodeDemo\VuejsApp\blog\node_modules\rollup\dist\shared\rollup.js:19744:34)
at async Promise.all (index 0)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @0.0.0 build: vue-tsc --noEmit && vite build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

LuoCore的主页 LuoCore | 初学一级 | 园豆:122
提问于:2021-07-13 15:21
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册