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函数中 不能正确渲染 依赖计算属性(get)的标签 #728

Closed
LOWINC opened this Issue Sep 28, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@LOWINC

LOWINC commented Sep 28, 2018

问题描述
[问题描述:render中能正常打印 计算属性 但是不能渲染

loading,hasData 来自redux,是接口返回的数据

问题代码

class Demo extends Component {

  get isShowDataView () {
    const { loading, hasData } = this.props
    return !loading && hasData
  }

  get isShowNoView () {
    const { loading, hasData } = this.props
    return !loading && !hasData
  }

  render () {
    const { isShowDataView, isShowNoView } = this

    return (
      <View>
        {isShowDataView && <View>data list</View>}
        {isShowNoView && <View>sorry no data</View>}
      </View>
    )
  }
}


---

发现 redner写成如下形式可以正常渲染

  render () {
    const dataView = this.isShowDataView // 变量名不能相同
    const noView = this.isShowNoView

    return (
      <View>
        {dataView && <View>data list</View>}
        {noView && <View>sorry no data</View>}
      </View>
    )
  }

系统信息

  • 操作系统: Windows 10]
  • Taro 版本 [e.g. v.1.0.5]
  • Node.js 版本 [e.g. v10.8.0]

@yuche yuche self-assigned this Sep 28, 2018

@yuche yuche closed this in 20ed37e Sep 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment