浅谈vue的踩坑路

(编辑:jimmy 日期: 2024/9/29 浏览:2)

------>axios模拟get json一直拿不到文件,先把data放到根目录,再去dev-server.js(就是npm执行的那个文件)里面设置静态资源访问路径app.use('/data',express.static('./data'))

...
app.use(hotMiddleware)

// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))

app.use('/data',express.static('./data'))/*其实只有这一行,特别注意,这个不加拿不到json*/

var uri = 'http://localhost:' + port
...

------->拿不到图片,因为webpack打包后文件的名字可能会改变,so要看webpack的配置文件

{
  test: /\.(png|jpe"htmlcode">
 [{
 "gname":"小米MIX3",
 "price":"3499",
 "img":"http://localhost:8082/static/img/mix5.png",
 "goods_des":"OLED 显示屏幕,升级计步算法",
 "review":"听说小米客服美眉很厉害送我一首藏头诗可好我爱钱天玉",
 "review_author":"来自橙子的"
},{
 "gname":"小米MIX4",
 "price":"3499",
 "img":"http://localhost:8082/static/img/mix5.png",
 "goods_des":"6.4 全面屏,全陶瓷机身"
}]

好,for循环的时候就要在相应的地方加上判断

<li v-for="(item,index) in arrList" class="goods-list-item">
 <span class="flag flag-new">{{item.flag}}</span>
 <a href="#" rel="external nofollow" class="img-wrap">
  <img :src="/UploadFiles/2021-04-02/item.img">

以上这篇浅谈vue的踩坑路就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

一句话新闻

Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。