Skip to content
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

【快应用】脚本中有除了render之外的方法去返回组件时,不管在render中是否调用了该方法,最终都会生成多个template标签 #4189

Open
M075097 opened this issue Aug 16, 2019 · 1 comment
Assignees
Labels
T-quickapp Target - 编译到快应用

Comments

@M075097
Copy link

M075097 commented Aug 16, 2019

问题描述
在脚本中如果有除了render方法之外的方法返回一个组件(即使该方法没有在render中调用),最终也会输出到生成的模版中,最终编译结果类似如下:

<template>
 <template>
 ...该处为调用的方法返回的模版
 </template>
 <div>
 ....
 </div>
</template>

复现步骤
在脚本定义一个方法用来返回一个组件

  renderList() {
    const {listData} = this.state;
    return listData.map((item,index) => {
      return <MovieItem data={item} key={item._key} />;
    });
  }

  render() {
    const {errorOpts = {}, isLoadingMore, adData = {}, popupModule} = this.state;
    const bannerData = adData[AD_CODE.indexBanner];
    const ballData = adData[AD_CODE.ballArea];
    const isNoPageError = !errorOpts.isShow;
    const isShowPopup = popupModule && isNoPageError;

    return (
      <View>
        {isNoPageError && (
          <View className="now-showing-list">
            {this.renderList()}//此处不管是否实际调用最终该方法中的View都会输出
            {isLoadingMore && <AtLoadMore isLoading={true} />}
          </View>
        )}
        {!isNoPageError && <PageError opts={errorOpts} onClick={this.handleErrorBtnClk} />}
      </View>
    );
  }

期望行为
能够正确以div标签包括调用方法生成的组件内容

系统信息

  • 操作系统: [Android]
  • Taro 版本 [v.1.3.13]
  • Node.js 版本 [v8.11.2]
@taro-bot
Copy link

taro-bot bot commented Aug 16, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-quickapp Target - 编译到快应用
Projects
None yet
Development

No branches or pull requests

3 participants