三元运算无法执行,?

小程序 文章 2021-04-08 16:42 377 0 全屏看文

AI助手支持GPT4.0

三元运算无法执行,?The ternary operation cannot be executed,

三元运算无法执行,?

小弟想做个样式更改的,但不知为啥三元运算没结果出来 求大佬指导

hxml

 <scroll-view class="left_content" scroll-y>    <view class="cata_name {{num==cur_num? 'active' : ' '}}" wx:for="{{catagory_left_list}}" wx:for-item="cata_item" wx:key="cata" data-num="{{index}}" bindtap="changePage">{{cata_item.cat_name}}</view>  </scroll-view>

js

data: {    catagory_left_list:[],    catagory_right_list:[],    cur_num:0  }changePage:function(e){    console.log(e)    let index = e.currentTarget.dataset.num;    this.setData({      cur_num:index,      catagory_right_list:this.catas[e.currentTarget.dataset.num].children    })  }

小弟想做个样式更改的,但不知为啥三元运算没结果出来 求大佬指导 hxml      {{cata_item.cat_name}}   js data: {    catagory_left_list:[],    catagory_right_list:[],    cur_num:0  }changePage:function(e){    console.log(e)    let index = e.currentTarget.dataset.num;    this.setData({      cur_num:index,      catagory_right_list:this.catas[e.currentTarget.dataset.num].children    })  }

回答:

null:
{{index==cur_num?'active':''}}
ᝰꫛꫀꪝ .:

<view wx:for="{{navList}}" wx:key="item" data-id="{{item.id}}" data-current="{{index}}" bindtap="swichNav" class="{{index == currentTab ? 'active' : ''}}">{{item.name}}</view>

wx:for放在前面 class在后面,可查看以上代码

brave:
{{num==cur_num? 'active' : ' '}}" 改成 {{index==cur_num? 'active' : ' '}}
AnDrew:

if 和 for 不要在同一个标签使用

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
图片检测无法检测?
iOS,Android授权企业微信登录,为什么显示网站?
微信7.0.17和7.0.16之前的“小程序主体信息主页显示”布局不一样,请问开发者可否控制?
加了广告代码,开发版可以看到,发布之后就看不到?
通过普通链接二维码打开小程序,如何在小程序指向页面获取二维码中的动态传参?
随便看看
按照文档的配置,小程序A跳转至小程序B提示页面不存在?而且只有我的手机可以,其他所有的手机都不行! 421
swiper-item中的图片如何进行居中显示? 1031
微信支付问题? 533
推送“支付完成事件”给开发者后,开发者5秒内没有返回 724
button 中的 open-type开放了很多功能,请问能用事件bindtap打开吗? 592
微信公众平台授权异常, 系统已修复这个错误, 请刷新页面重试 1531
如何把多个数组合成二级数组(数组中的数组)? 451
具备7个系列19种行业的商家需要你供货,你能吃得消吗?不是没生意而是你没选对项目做吗? 302
页面样式? 366
这是什么原因? 304