(调用接口时同时请求type)三元运算与接口对象初始化

1.{{Item(对象).shop(对象)?item.shop.shopname:''}}因VUE框架问题数据在请求接口里,字段没有初始化{对象里面的对象在初始化里没有找到会报错}

2.目的:在调用接口时同时请求type

Return{collectType: 'goods',}  //数据初始化

async loadData() {

let res = await this.$http.post("/api/collects/PClist", {

session: true,

type: this.collectType, //type定义变量

page: this.page,

pagesize: "",

})

handleTabClick(index) {

this.tabIndex = index;

this.tomore = index==0?'/goodsCollect':'/storeCollect';

this.collectType = index==0?'goods':'shop';//三元运算

this.loadData();//方法调用

},

3.vue限制循环次数

<div class="list_detail" v-for="(item,index) in result" v-if="(item,index)<8">

猜你喜欢

转载自www.cnblogs.com/Glant/p/10602098.html
今日推荐