浅谈vue的踩坑路
网络编程 2021-07-04 18:33www.168986.cn编程入门
狼蚁网站SEO优化长沙网络推广就为大家带来一篇浅谈vue的踩坑路。长沙网络推广觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随长沙网络推广过来看看吧
------>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?g|gif|svg)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, /* name: utils.assetsPath('img/[name].[hash:7].[ext]')这个会改变图片的名字*/ name: utils.assetsPath('img/[name].[ext]') }<br>}
------->数据里面的值有一些有有一些没有,如下这种
[{ "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="item.img" /><!--或者v-bind:src="item.img"--> </a> <h3 class="good-title"><a href="">{{item.gname}}</a></h3> <p class="good-desc">{{item.goods_des}}</p> <p class="good-price">{{item.price}}</p> <p class="review-wrap" v-if="item.review"><!--如果review存在就显示--> <a href=""> <span class="review">{{item.review}}</span> <span class="author">{{item.review_author}}</span> </a> </p> </li>
以上这篇浅谈vue的踩坑路就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程