相关平台
微信小程序
小程序基础库: 2.12.2
使用框架: React
复现步骤
renderItemAreas = (item) => {
if (item && item.Areas) {
const { Areas } = item
const isShow = Areas.length > 0
return (
<View className='content'>
{isShow ? (
Areas.map((it) => {
return (<View
className='item'
key={it.id}
>
{it.name} // 改为 JSON.stringify(it.name) 则正常
</View>)
})
) : (<View>测试 </View>)}
</View>)
}
}
在render() 中调动 renderItemAreas 即重现
期望结果
渲染正常
实际结果
VM21280 WAService.js:2 MiniProgramError
Areas is not defined
ReferenceError: Areas is not defined
at http://127.0.0.1:55124/appservice/components/PlayTask/PlayTask.js?t=wechat&s=1609208768580&v=632166dee89ed9d5da31b15d75ea0bee:334:18
at http://127.0.0.1:55124/appservice/components/PlayTask/PlayTask.js?t=wechat&s=1609208768580&v=632166dee89ed9d5da31b15d75ea0bee:264:172
at Array.map ()
at PlayTask._createData ( http://127.0.0.1:55124/appservice/components/PlayTask/PlayTask.js?t=wechat&s=1609208768580&v=632166dee89ed9d5da31b15d75ea0bee:260:61 )
at doUpdate ( http://127.0.0.1:55124/appservice/taro.js?t=wechat&s=1609208768580&v=eadd729d90f99d2457eeadf985046c2c:2913:22 )
at updateComponent ( http://127.0.0.1:55124/appservice/taro.js?t=wechat&s=1609208768580&v=eadd729d90f99d2457eeadf985046c2c:2840:5 )
at rerender ( http://127.0.0.1:55124/appservice/taro.js?t=wechat&s=1609208768580&v=eadd729d90f99d2457eeadf985046c2c:3029:7 )
at http://127.0.0.1:55124/appservice/taro.js?t=wechat&s=1609208768580&v=eadd729d90f99d2457eeadf985046c2c:3018:7
at
环境信息
Taro CLI 2.0.4 environment info:
System:
OS: macOS Sierra 10.12
Shell: 5.2 - /bin/zsh
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 2.0.4 => 2.0.4
@tarojs/components-qa: 2.0.4 => 2.0.4
@tarojs/mini-runner: 2.0.4 => 2.0.4
@tarojs/router: 2.0.4 => 2.0.4
@tarojs/taro: 2.0.4 => 2.0.4
@tarojs/taro-alipay: 2.0.4 => 2.0.4
@tarojs/taro-h5: 2.0.4 => 2.0.4
@tarojs/taro-qq: 2.0.4 => 2.0.4
@tarojs/taro-quickapp: 2.0.4 => 2.0.4
@tarojs/taro-rn: 2.0.4 => 2.0.4
@tarojs/taro-swan: 2.0.4 => 2.0.4
@tarojs/taro-tt: 2.0.4 => 2.0.4
@tarojs/taro-weapp: 2.0.4 => 2.0.4
@tarojs/webpack-runner: 2.0.4 => 2.0.4
eslint-config-taro: 2.0.4 => 2.0.4
eslint-plugin-taro: 2.0.4 => 2.0.4
nerv-devtools: ^1.5.5 => 1.5.7
nervjs: ^1.5.7 => 1.5.7
stylelint-config-taro-rn: 2.0.4 => 2
4条答案
按热度按时间7eumitmz1#
Areas.map
直接写成item.Areas.map
呢1cosmwyk2#
@luckyadam 写成后面这种item.Areas.map 就不会报错。
wqsoz72f3#
@luckyadam 写成后面这种item.Areas.map 就不会报错。
那先这么写吧,2.x最新版本应该解决了这个问题,但升级估计你会遇到麻烦,可以不升级
ecbunoof4#
@luckyadam 写成后面这种item.Areas.map 就不会报错。
那先这么写吧,2.x最新版本应该解决了这个问题,但升级估计你会遇到麻烦,可以不升级
对,我就是怕升级遇到问题,所以没敢升级,谢谢。