猿问

vue cli项目,build后图片路径的问题?

1、使用vue init webpack-simple构建了项目,目录结构如下图

2、在vue的组件中
<img src="/static/clinicpackage/clinicbanner.jpg" alt="">
引入图片
3、项目部署后,由于项目使放在域名http···.com/static下面,图片的路径就错了,请问怎么解决?


holdtom
浏览 1475回答 3
3回答

森栏

assetsPublicPath: './'

慕尼黑8549860

assetsPublicPath: './'utils.jsif (options.extract) {&nbsp; &nbsp; &nbsp; return ExtractTextPlugin.extract({&nbsp; &nbsp; &nbsp; &nbsp; use: loaders,&nbsp; &nbsp; &nbsp; &nbsp; fallback: 'vue-style-loader',&nbsp; &nbsp; &nbsp; &nbsp; publicPath:'../../'&nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; return ['vue-style-loader'].concat(loaders)&nbsp; &nbsp; }webpack.base.conf{&nbsp; &nbsp;test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,&nbsp; &nbsp;loader: 'url-loader',&nbsp; &nbsp;options: {&nbsp; &nbsp; &nbsp;limit: 10000,&nbsp; &nbsp; &nbsp;name: utils.assetsPath('img/[name].[hash:7].[ext]'),&nbsp; &nbsp; &nbsp;outputPath: process.env.NODE_ENV === 'production' ? '../' : ''&nbsp; }},
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答