使用img标签时候报路径错误

报错信息

at formatError (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:50863:46) at TransformContext.error (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:50857:19) 21:21:33 [vite] Internal server error: Failed to resolve import "src/assets/images/Banner1.jpg" from "src/views/Home/components/Homebanner.vue". Does the file exist? Plugin: vite:import-analysis File: D:/learn/Project/IURunning/iurf/Vue-IURF/src/views/Home/components/Homebanner.vue:4:46 35 | 36 | import { createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue" 37 | import _imports_0 from 'src/assets/images/Banner1.jpg' | ^ 38 | import _imports_1 from 'src/assets/images/Banner2.png' 39 | at formatError (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:50863:46) at TransformContext.error (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:50857:19) at normalizeUrl (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:66092:33) at async file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:66247:47 at async Promise.all (index 13) at async TransformContext.transform (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:66168:13) at async file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite-plugin-inspect/dist/index.mjs:377:17 at async Object.transform (file:///D:/learn/Project/IURunning/iurf/Vue-IURF/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:51172:30) at async

报错原因

<img :src='src\assets\images\Banner1.jpg' alt=""> 如果只用一个 \ 会报错因为这个\已经有特定的含义了

解决办法

使用 转义字符 把\ 转换成\ 。2个\\ = \

所以 加一个\ 就不会报错了 <img :src='src\\assets\\images\\Banner1.jpg' alt="">

相关推荐
Cool----代购系统API11 分钟前
css设置盒子动画,CSS3 transition动画 animation动画
前端·css·css3
哟哟耶耶21 分钟前
css-设置元素的溢出行为为可见overflow: visible;
前端·css
sunly_24 分钟前
CSS:跑马灯
前端·css
2301_8187320632 分钟前
用layui表单,前端页面的样式正常显示,但是表格内无数据显示(数据库连接和获取数据无问题)——已经解决
java·前端·javascript·前端框架·layui·intellij idea
yqcoder33 分钟前
npm link 作用
前端·npm·node.js
林涧泣38 分钟前
【Uniapp-Vue3】页面和路由API-navigateTo及页面栈getCurrentPages
前端·vue.js·uni-app
Komorebi゛41 分钟前
【uniapp】获取上传视频的md5,适用于APP和H5
前端·javascript·uni-app
林涧泣1 小时前
【Uniapp-Vue3】动态设置页面导航条的样式
前端·javascript·uni-app
杰九1 小时前
【全栈】SprintBoot+vue3迷你商城(10)
开发语言·前端·javascript·vue.js·spring boot
Hopebearer_2 小时前
入门 Canvas:Web 绘图的强大工具
前端·javascript·es6·canva可画