New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map 循环调用 render 方法渲染的组件不能在事件方法中获取正常遍历参数 #5946
Comments
CC @luckyadam |
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
这个bug可以通过生成的代码看出来。 function _createItemsData(_$uid) {
var _this2 = this;
return function (arr_item, index) {
var loopArray2 = arr_item.map(function (item, __index0) {
item = {
$original: (0, _taroWeapp.internal_get_original)(item)
};
var $loopState__temp2 = (0, _taroWeapp.internal_inline_style)(_this2.grandItemStyle(index));
var $loopState__temp4 = "arr_item_" + item.$original;
var _$indexKey = "czzzz" + __index0;
_this2.anonymousFunc0Map[_$indexKey] = function () {
_taroWeapp2.default.showToast({ title: "\u6211\u70B9\u4E86" + item.$original });
};
return {
$loopState__temp2: $loopState__temp2,
$loopState__temp4: $loopState__temp4,
_$indexKey: _$indexKey,
$original: item.$original
};
});
return {
loopArray2: loopArray2,
arr_item: arr_item
};
};
} 由于arr1和arr2共用了一个_createItemsData,而代码 // taro-transformer-wx/src/class.ts line 263
t.binaryExpression('+', t.stringLiteral(createRandomLetters(5)), index) 生成的随机字符串。 源码改动是 提了一个pr |
1.42 版本的hook编写的页面也有这个问题。render 函数渲染的组件不能在事件方法中获取正常遍历参数,在render函数中再用map,map中调用函数的参数会一样。 |
https://wudi98.blog.csdn.net/article/details/105778616 |
Taro3 应该没有这个问题了。 |
好的,谢谢回复。
…------------------ 原始邮件 ------------------
发件人: "chenjiajian"<notifications@github.com>;
发送时间: 2020年7月2日(星期四) 下午4:13
收件人: "NervJS/taro"<taro@noreply.github.com>;
抄送: "web前端--"<1336791007@qq.com>; "Comment"<comment@noreply.github.com>;
主题: Re: [NervJS/taro] map 循环调用 render 方法渲染的组件不能在事件方法中获取正常遍历参数 (#5946)
Taro3 应该没有这个问题了。
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
问题描述
描述:当 map 遍历渲染组件时,被渲染的组件不能在类似于 onClick 事件中获取正常的遍历参数,遍历值始终是最后一个遍历的数据
我提了两个类似的问题 #5473 和 #5138,都是类似的问题,但是至今都没有任何有用回复就关闭了
像 #5473 和 #5138 这种原生组件(
Switch, Picker
)才会发生的问题,现在普通 View 也会了!顺便提一下,真的挺怀疑 taro-bot 的 issue 管理中所谓的:
如果您在这 15 天中更新更多信息自动关闭的流程会自动取消
是不是真的有效。复现步骤
微信小程序开发工具
,不知道是否有关)期望行为
事件函数可以正常获取遍历参数
报错信息
没有报错信息,我还是像 #5473 一样贴一张运行gif
https://gfycat.com/snivelingdecimalemperorshrimp
系统信息
👽 Taro v2.1.4
Taro CLI 2.1.4 environment info:
System:
OS: macOS 10.15.4
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
Yarn: 1.22.0 - ~/.yarn/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v10.16.3/bin/npm
npmPackages:
@tarojs/components: 2.1.4 => 2.1.4
@tarojs/mini-runner: 2.1.4 => 2.1.4
@tarojs/plugin-babel: 2.1.4 => 2.1.4
@tarojs/plugin-csso: 2.1.4 => 2.1.4
@tarojs/plugin-sass: 2.1.4 => 2.1.4
@tarojs/plugin-uglifyjs: 2.1.4 => 2.1.4
@tarojs/router: 2.1.4 => 2.1.4
@tarojs/taro: 2.1.4 => 2.1.4
@tarojs/taro-alipay: 2.1.4 => 2.1.4
@tarojs/taro-h5: 2.1.4 => 2.1.4
@tarojs/taro-qq: 2.1.4 => 2.1.4
@tarojs/taro-quickapp: 2.1.4 => 2.1.4
@tarojs/taro-swan: 2.1.4 => 2.1.4
@tarojs/taro-tt: 2.1.4 => 2.1.4
@tarojs/taro-weapp: 2.1.4 => 2.1.4
@tarojs/webpack-runner: 2.1.4 => 2.1.4
eslint-config-taro: 2.1.4 => 2.1.4
eslint-plugin-taro: 2.1.4 => 2.1.4
nerv-devtools: ^1.5.6 => 1.5.6
nervjs: ^1.5.6 => 1.5.6
stylelint-config-taro-rn: 2.1.4 => 2.1.4
stylelint-taro-rn: 2.1.4 => 2.1.4
taro-ui: ^2.3.3 => 2.3.3
补充信息
Taro CLI 2.1.4 environment info:
System:
OS: macOS 10.15.4
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
Yarn: 1.22.0 - ~/.yarn/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v10.16.3/bin/npm
npmPackages:
@tarojs/components: 2.1.4 => 2.1.4
@tarojs/mini-runner: 2.1.4 => 2.1.4
@tarojs/plugin-babel: 2.1.4 => 2.1.4
@tarojs/plugin-csso: 2.1.4 => 2.1.4
@tarojs/plugin-sass: 2.1.4 => 2.1.4
@tarojs/plugin-uglifyjs: 2.1.4 => 2.1.4
@tarojs/router: 2.1.4 => 2.1.4
@tarojs/taro: 2.1.4 => 2.1.4
@tarojs/taro-alipay: 2.1.4 => 2.1.4
@tarojs/taro-h5: 2.1.4 => 2.1.4
@tarojs/taro-qq: 2.1.4 => 2.1.4
@tarojs/taro-quickapp: 2.1.4 => 2.1.4
@tarojs/taro-swan: 2.1.4 => 2.1.4
@tarojs/taro-tt: 2.1.4 => 2.1.4
@tarojs/taro-weapp: 2.1.4 => 2.1.4
@tarojs/webpack-runner: 2.1.4 => 2.1.4
eslint-config-taro: 2.1.4 => 2.1.4
eslint-plugin-taro: 2.1.4 => 2.1.4
nerv-devtools: ^1.5.6 => 1.5.6
nervjs: ^1.5.6 => 1.5.6
stylelint-config-taro-rn: 2.1.4 => 2.1.4
stylelint-taro-rn: 2.1.4 => 2.1.4
taro-ui: ^2.3.3 => 2.3.3
The text was updated successfully, but these errors were encountered: