areslabs / alita

一套把React Native代码转换成微信小程序代码的转换引擎工具。我们不造轮子,不发明新框架,只是提供工具把RN扩展到微信小程序端。

Home Page:https://areslabs.github.io/alita

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

生成模板找不到 template not found

yatessss opened this issue · comments

<TouchableOpacity
          onPress={() => {
            this.props.onPress()
          }}>
            {this.props.disabled
              ? <View style={{opacity: 0.3}}>{this.props.children}</View>
              : this.props.children}
        </TouchableOpacity>

组件内写了类似的三目运算后,模板不会生成,编译也不会有报错

应该不是 三目运算的问题,你把 this.props. children 换成 <Text>1</Text> 试试看, 可能是this.props.children的问题

改为<Text>1</Text>是可以的,不过我传入的是一段element,尝试了一下是在children外面包裹view就可以了

<TouchableOpacity
          onPress={() => {
            this.props.onPress && this.props.onPress()
          }}>
          {this.props.disabled ? <View style={{opacity: 0.3}}>{this.props.children}</View> : <View>{this.props.children}</View>}
        </TouchableOpacity>

我看下

@yatessss 问题定位到了,正在修复。 暂时可以

<TouchableOpacity
          onPress={() => {
            this.props.onPress()
          }}>
            {this.props.disabled
              ? <View style={{opacity: 0.3}}>{this.props.children}</View>
              : <View>{this.props.children}</View>}
        </TouchableOpacity>

下面没有被JSX元素包裹的this.props.children 没有被识别。

嗯。你说的对。 “奇奇怪怪的报错” 你可以加我QQ(1527997464)发我, 我应该可以定位出哪里出了问题。 filepath的确应该加上,我想一想

嗯。 关于原理,我有时间 整理一下,其实主要就是一种让小程序支持JSX语法的新思路, 另外加上 小程序 实例和React实例建立关系的过程。

log会一步步完善

非常欢迎一起修复 😄 😄