WX:FOR的使用问题?

小程序 文章 2020-08-10 17:21 614 0 全屏看文

AI助手支持GPT4.0

WX:FOR的使用问题?WX: How to use FOR?

WX:FOR的使用问题?

本人使用WX:FOR 循环渲染了第二层标签,右下角有个圆形ICON标签,默认初始化是不显示的。第二层的每个标签都会跟着一些问题。本人的设计是第三层问题只要被回答了,ICON标签就显示。这样意味着,第二层标签在渲染的时候要赋予每个ICON标签一个ID值,并唯一标识其是否显示,比如用wx:if来搞定。可本人在如何充分利用WX:FOR时生成这些需具备能控制其是否显示的唯一标识的时候没想到有什么有效的办法?请高人指定!谢谢。注意是;第三层问题回答了,就显示对应的第二册标签。当然第二层标签点击了,显示自己相关的问题。如下下图中,6个标签对应6组问题。麻烦了。

下面写的这个wx:if="out{{index+1}}" 貌似是字符串,无法起作用?

WXML:

<view class="layer2boxwx:if="{{isShowOut}}">

  <view wx:for="{{outlist}}class="item-list {{index+1==current?'select':''}}wx:key="idbindtap="onClickL2Outdata-id="{{item.id}}">

    <view>{{index+1}}_{{item.title}} view>

    <icon wx:if="out{{index+1}}type="successsize="20rpxcolor="{{iconcolor}}"> icon>

   view>

view>



I used Wx: for loop to render the second layer label. There is a circular icon label in the lower right corner. The default initialization is not displayed. Each label in the second layer has some problems. My design is the third level of questions, as long as they are answered, the icon tag will be displayed. This means that each icon tag should be given an ID value when rendering, and uniquely identify whether it is displayed, such as Wx: if. But when I make full use of Wx: for, I didn't think of any effective way to generate the unique identification that can control whether it is displayed or not? Please specify! thank you. Note: the third question is answered, and the corresponding volume 2 label will be displayed. Of course, the second layer of tabs Click to display their own related questions. In the following figure, six tags correspond to six groups of questions. Sorry for the inconvenience. The Wx: if = out {index + 1}} "seems to be a string, so it doesn't work? WXML: {{index+1}}_ * item.title }}view> icon> view> view>

回答:

?:

wx:if 成立的条件是 不为空 不为null 不为undefined 不为负数。但是你这样子写 他都是true。

Jason_亮 🇨🇳:明白。那怎么写呢?或者使用别的思路?刚才根据别人的建议,写成"{{out[index+1]}}"也不行。
?:你这里第三层和第二层是怎么对应的?还是说第三层就在第二层的下面?也是第二层循环里的子元素?
Jason_亮 🇨🇳:第二层每个大控件对应第三层一组问题,问题回答即显示其第二层对应标签右下角的小ICON标签。第三层就在第二层的下面,第三层根据第二层控件的点击出来,究竟循环出来还是罗列出来,不在当前问题范围。
Distance:

wx:if="out{{index+1}}" 因为out是字符串所以不管你index+1是什么,他都是true

Jason_亮 🇨🇳:明白。那怎么写呢?或者使用别的思路?刚才根据别人的建议,写成"{{out[index+1]}}"也不行。
Why not?:

wx:if="out{{index+1}}" 不知道out是啥东西,但应该是个变量吧,你得这么写:wx:if="{{out[index+1]}}"

Jason_亮 🇨🇳:这样写也不可以啊,index+1外面不论是()或[]均不可以,这样,连wxml渲染都看不到了。我这里探讨的不仅仅是这个写法的问题,估计这么写根本就写不出准确的方式,需要换个别的思路?有建议吗?

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
经用户投诉并经平台审核,你的帐号涉嫌过度营销, 已屏蔽新增模板功能模板消息 能不能解除呢?
小程序要自己写代码吗?
我开了手机怎么进去,每次进都要从电脑扫码进去吗?
大家都是如何处理后台 tomcat 重启导致session失效,接口请求不成功需要重新登录的问题的?
小程序拍照不能获取原图问题?
随便看看
地图如何只显示某省市区的板块?其他全部隐藏。 2105
获取access_token接口,设置IP白名单问题,求官方解答 1017
iphone12 和 13 打开使用 web_view的小程序,关闭后打开白屏 求官方解答? 456
通过普通链接二维码打开小程序,如何在小程序指向页面获取二维码中的动态传参? 426
JSAPI支付和Native支付权限冻结,麻烦恢复一下~谢谢! 497
开通虚拟支付也是提示系统繁忙? 303
测试号报错,invalid appsecret? 963
微信支付jsapi缺少参数total_fee?有参数图 406
请问一下,什么条件下才可以申请获取当前的地理位置、速度 权限? 553
<image> 有时候报Failed to load local image resource? 2774