这是在写订单页面时遇到的坑。(if不能用)
当时需要判断订单状态,所以用了三元运算
当时我把map的return给包住了,这样会报出找不到item的错误

//{this.state.list.map((item, i) => {{item.state==0?<View>return(<View><View className='flex-wrp view-order-column' style='flex-direction:column;' for={i} key={i}><View className='at-row margin-top10 order-form-number'><View>订单编号:</View><View>{item.code}</View></View><AtAccordionopen={this.state.open[i]}onClick={this.handleClick.bind(this,i)}title='具体课程'>{item.purchased.map((items,i) => {return (              <View >               <AtList hasBorder={false} for={i} key={i}><AtListItemtitle={items.product_name}extraText={items.shop_name}/></AtList></View>)})}</AtAccordion> <View className='at-col'><AtTag type='primary'className='rigthpanyi tag-color-FuKuan'>待付款</AtTag></View>              <View className='fone-one1 margin-top10 at-row'><View>实付金额:</View><View>{item.total}</View></View><View className='fone-one1 margin-top10 at-row'><View>时间:</View><View>{item.created_at}</View></View><AtDivider height="40" /></View></View>)</View>:null}})}

正确用法↓

 return(<View><View className='flex-wrp view-order-column' style='flex-direction:column;' for={i} key={i}>{item.state==0?<View><View className='at-row margin-top10 order-form-number'><View>订单编号:</View><View>{item.code}</View></View><AtAccordionopen={this.state.open[i]}onClick={this.handleClick.bind(this,i)}title='具体课程'>{item.purchased.map((items,i) => {return (              <View >               <AtList hasBorder={false} for={i} key={i}><AtListItemtitle={items.product_name}extraText={items.shop_name}/></AtList></View>)})}</AtAccordion> <View className='at-col'><AtTag type='primary'className='rigthpanyi tag-color-FuKuan'>待付款</AtTag></View>              <View className='fone-one1 margin-top10 at-row'><View>实付金额:</View><View>{item.total}</View></View><View className='fone-one1 margin-top10 at-row'><View>时间:</View><View>{item.created_at}</View></View><AtDivider height="40" /></View>:null}</View></View>)})}

taro里的三元运算判断与map循环相关推荐

  1. php 三元运算判断,PHP 条件判断语句和三元运算符

    $n1=1000; $n2=1000; $n3=100; $n4=100; // if 语句 - 如果指定条件为真,则执行代码 // if...else 语句 - 如果条件为 true,则执行代码:如 ...

  2. PHP使用三元运算判断变量

    // (expr1)?(expr2):(expr3); $a=1; $b=2; $c= $a==5 ? $a1=4 : $d=d;//如果$a条件成立就返回$a1否则就返回$d echo $c;//输 ...

  3. vue 绑定多个class 顺便带上三元运算 判断

    :class="[computedView(item.n)?'numberParty':'numberCircle',{'select-active':items.istrue}]" ...

  4. java中数字作为布尔值_day50 java Script 数字和字符串 布尔值和数组 运算符 条件判断和三元运算...

    上节回顾: day501.前情回顾 CSS属性: float浮动的规则1. 浮动规则: 浮动只控制自己 如果前面的标签也是浮动的,就挨着放 如果前面的标签不浮动,则下方摆放 如果把块级标签设置成浮动, ...

  5. php 三元运算 简写,es6 三元运算(三元类目)符语法与简写,多条件判断与??::形式 - Laravel学习网...

    三元运算符就是替代传统if-else语句让更简洁. 一.三元运算标准写法 我们传统的写法为: const x = 20; let answer; if (x > 10) { answer = ' ...

  6. 深浅拷贝、函数、内置函数、文件处理、三元运算、递归

    深浅拷贝 import copy copy.copy() #浅拷贝 copy.deepcopy() #深拷贝 num = 110 copynum = num #赋值 一.数字和字符串 对于 数字 和 ...

  7. Python基础(三)深浅拷贝、函数、文件处理、三元运算、递归、冒泡排序

    本章内容: 深浅拷贝 函数(全局与局部变量) 内置函数 文件处理 三元运算 lambda 表达式 递归(斐波那契数列) 冒泡排序 深浅拷贝 一.数字和字符串 对于 数字 和 字符串 而言,赋值.浅拷贝 ...

  8. 01 Python学习--第一周--开课介绍、数据类型、数据运算、表达式、循环、三元运算、对象基本概念...

    模块一主要内容 开课介绍 python发展介绍 第一个python程序 变量 字符编码与二进制 字符编码的区别与介绍 用户交互程序 if else流程判断 while 循环 while 循环优化版本 ...

  9. 第三章、三元运算、文件处理、函数

    第三章.三元运算.文件处理.函数 三元运算 三元运算又称三目运算,是对简单的条件语句的简写,如: 简单条件语句: if 条件成立:val = 1 else:val = 2 # 可以写成如下: val ...

最新文章

  1. 一个基于SpringBoot + Mybatis + Vue的代码生成器
  2. Single molecule real-time (SMRT) sequencing comes of age: applications and utilities for medical dia
  3. linux 下安装nodejs,CentOS 6.5 系统
  4. 【转】VS2005 CTP 版本这个CTP是什么意思
  5. [NOI2013]树的计数
  6. 08 | RNN 与 LSTM:模型也可以持续不断地思考
  7. (非)对称加密算法在https中的应用(加密过程以及CA颁发、验证)
  8. 小谈EasyUI中的tree用法
  9. STM32F405 HAL库 STM32CUBE开发
  10. 当汽车工业遇见 AI,开发者的时代到来
  11. 学习笔记——正则匹配方法整理
  12. 【Codeforces Round #516_div2】Labyrinth【迷宫搜索】
  13. 碎碎念集萃三零【静心】
  14. C++ 多线程学习总结
  15. 第十周项目2——贮存班长信息的学生类
  16. 最简单明了的QQ在线客服代码
  17. Android绝黑剑之AutoCompleteTextView、MultiAutoCompleteTextView之智能联想
  18. TP-LINK路由器自动拨号上网和无线上网设置
  19. 加密算法之MD5算法
  20. asm(” RPT #N || NOP”)

热门文章

  1. debian系统用spack安装cuda和cudnn
  2. mdk 使用arm complier v6开启FPU报错问题
  3. python字符串可变吗_python中不可变数据类型和可变数据类型
  4. java隋唐系列游戏下载,隋唐大业全面战争
  5. 怎样建网站赚钱企业建网站,网站建设的好处!
  6. 华为中级认证HCIP知识点总结,网工收藏
  7. 英文期刊等级查询网址
  8. 利用Unity3D与Oculus实现机器情绪安抚师的一种方案
  9. 使用标准信号检测 VM振弦采集模块测量精度修正
  10. 电商货源模式有哪些?萌啦带你找到合适货源!