Taro 里引用class组件,不能引用function组件吗?
-
父组件引用组件:
import AAA from './components/AAA'
子组件(Function定义),不能正常引用:
export default function AAA() { return( <View className='index'> <Text>Hello world!</Text> </View> ) }
报错:
错误 页面编译 页面/Users/***/Desktop/test/src/pages/index/index编译失败! TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received type object
子组件(Class定义),就能正常引用:
export default class AAA extends Component<any, any> { render () { return ( <View className='index'> <Text>Hello world!</Text> </View> ) } }
如果子组件用 Hooks 模式,就只能用 function 组件?那 Taro 该如何调用这种组件?
-
没能复现,你做一个复现仓库吧
-
我也是一样只要用函数式组件,微信小程序编译就会报错