We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述
在 tsx(jsx) 中使用 {array.map(...)} 语法渲染列表时,若列表项为原生微信小程序自定义组件(即混写小程序组件),自定义事件的绑定只能为该 Taro.Component 类的非柯里化的方法。当试图为自定义组件绑定柯里化的方法或者匿名函数(/lambda函数)时,会找不到方法控制台输出警告而绑定失败。
tsx
jsx
{array.map(...)}
Taro.Component
复现步骤
test-component.wxml
<view bind:tap="innerSoundTap">test</view>
test-component.ts
Component({ methods: { innerSoundTap() { this.triggerEvent('soundTap'); } }, });
learn.tsx
class Learn extends Component { config: Config = { usingComponents: { 'test-component': './test-component', }, }; render() { return ( <View class="wrapper"> {[1, 2].map(val => ( <test-component onSoundTap={this.onTestSoundTap(val)} /> ))} </View> ); } private onTestSoundTap = (val: number) => () => { console.log(val); } }
期望行为
事件成功绑定
报错信息
警告信息:
VM1962:1 Component "pages/learn/learn" does not have a method "anonymousFunc1.bind(this, value._$indexKey2)" to handle event "soundTap".
系统信息
Taro CLI 1.3.0-beta.3 environment info: System: OS: Windows 10 Binaries: Node: 10.13.0 - D:\Dev\Env\NodeJs\node.EXE Yarn: 1.16.0 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.4.1 - D:\Dev\Env\NodeJs\npm.CMD
补充信息 使用<View>作为列表项绑定onClick事件的wxml部分编译结果(行为正常):
<View>
wxml
<view bindtap="anonymousFunc1" wx:for="{{loopArray39}}" wx:for-item="value" wx:for-index="__index1" data-e-tap-so="this" data-e-tap-a-a="{{value._$indexKey2}}" > {{value.$original}} </view>
使用自定义原生微信小程序组件绑定自定义事件对应的wxml编译结果(行为不正常):
<test-component bindsoundTap="anonymousFunc1.bind(this, value._$indexKey2)" wx:for="{{loopArray35}}" wx:for-item="value" wx:for-index="__index1" __fn_onSoundTap="{{true}}" ></test-component>
可以推得Taro转译器的正确编译结果应为:
已验证的希望Taro能得到的正确编译结果(已验证:行为正常):
<test-component bindsoundTap="anonymousFunc1" wx:for="{{loopArray35}}" wx:for-item="value" wx:for-index="__index1" __fn_onSoundTap="{{true}}" data-e-soundTap-so="this" data-e-soundTap-a-a="{{value._$indexKey2}}" ></test-component>
The text was updated successfully, but these errors were encountered:
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
Sorry, something went wrong.
第三方组件不打算搞那么多花式方法了,给编译期徒增压力。准备在文档事件处理中写明第三方组件不能这么写。
2f9ac44
yuche
No branches or pull requests
问题描述
在
tsx
(jsx
) 中使用{array.map(...)}
语法渲染列表时,若列表项为原生微信小程序自定义组件(即混写小程序组件),自定义事件的绑定只能为该Taro.Component
类的非柯里化的方法。当试图为自定义组件绑定柯里化的方法或者匿名函数(/lambda函数)时,会找不到方法控制台输出警告而绑定失败。复现步骤
test-component.wxml
test-component.ts
learn.tsx
期望行为
事件成功绑定
报错信息
警告信息:
系统信息
Taro CLI 1.3.0-beta.3 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.13.0 - D:\Dev\Env\NodeJs\node.EXE
Yarn: 1.16.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.4.1 - D:\Dev\Env\NodeJs\npm.CMD
补充信息
使用
<View>
作为列表项绑定onClick事件的wxml
部分编译结果(行为正常):使用自定义原生微信小程序组件绑定自定义事件对应的
wxml
编译结果(行为不正常):可以推得Taro转译器的正确编译结果应为:
已验证的希望Taro能得到的正确编译结果(已验证:行为正常):
The text was updated successfully, but these errors were encountered: