Open
Conversation
SoloJiang
reviewed
Nov 24, 2021
| /** | ||
| * Judge whether the component has native compiled component | ||
| */ | ||
| if (pkg && pkg.miniappConfig && pkg.miniappConfig[`main:${platform}`]) node.name.isNative = true; |
SoloJiang
reviewed
Nov 24, 2021
| */ | ||
| module.exports = function isBaseComponent(node) { | ||
| // Rax base components and native base components are recognized as base components | ||
| return baseComponents.indexOf(node.name) > -1 || node && node.isNative; |
Contributor
There was a problem hiding this comment.
前面已经用到 node.name 了,这里不需要 node && node.isNative
Contributor
|
另外,几个内部变量最好写一下分别什么场景用的,现在确实有点乱了 |
Author
|
已更新~ |
SoloJiang
reviewed
Nov 24, 2021
| * Judge whether the component has native compiled component | ||
| * If it has, the property isNative should true, otherwise it would be false. | ||
| */ | ||
| node.name.isNative = !!getCustomComponentPath(pkg, platform) ? true : false; |
Contributor
There was a problem hiding this comment.
!!getCustomComponentPath(pkg, platform) 本身就是布尔值
SoloJiang
reviewed
Nov 24, 2021
| */ | ||
| const platformIdentifier = platform === 'ali' ? 'main' : `main:${platform}` | ||
| return pkg && pkg.miniappConfig && pkg.miniappConfig[platformIdentifier] || null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在原生小程序自定义组件中,如果想在这个组件的标签上挂一个事件,并在组件内通过triggerEvent来进行出发。
如
<NativeComp onClick={event} />,这里的NativeComp是一个npm原生小程序自定义组件。在组件内通过triggetEvent('onClick', e)的方式进行触发。这个组件应该被编译为<native-comp bindonClick="_e0" />这种形式,即对应的事件前应该有bind以允许出发该事件。而目前的编译结果仍然为
<native-comp onClick="_e0" />,编译结果与期望不一致。故支持通过判断该组件是否为原生组件,如果是则会将on开头的属性修改为bindon的格式,以支持事件绑定。