template 内使用 methods,v-if 无法获取函数返回值
<view v-if="isSingleSpec(item1)" >
<text>11</text>
</view>
isSingleSpec(food) {
// 判断是否是单规格
console.log("food.Name: ",food.Name);
if (food.Specs.length === 1) {
console.log("food.Attributes: ",food.Attributes);
for (let attr of food.Attributes) {
console.log("attr.Values.length: ",attr.Values.length);
if (attr.Values.length === 1) {
return true;
}
}
console.log("utils.isEmptyArray(food.Attributes): ",utils.isEmptyArray(food.Attributes))
return utils.isEmptyArray(food.Attributes);
}
return false;
},
IDE运行环境说明
[HBuilderX]
[## 1.8.2.20190401]
uni-app运行环境说明
[运行端是微信小程序]
0 个回复