导航

    Taro 社区

    Taro

    • 注册
    • 登录
    • 搜索
    • 版块
    • 最新
    • 话题
    • 热门
    • 群组
    1. 主页
    2. 六两
    3. 帖子
    六
    • 资料
    • 关注
    • 粉丝
    • 主题
    • 帖子
    • 最佳
    • 群组

    六两 发布的帖子

    • 引入子组件报错

      c75780ea-fa52-4fe6-92ae-12cd63104000-image.png

      父组件是这样
      import React, { Component } from 'react'
      import { View, Text, Button } from '@tarojs/components'
      import './index.less'
      import Child from './child.jsx';

      export default class Index extends Component {

      state = {
      name: 'Alex'
      }

      nameClick = () => {
      this.setState({ name: 'Joss' })
      }

      render() {
      const { name } = this.state;
      return (
      <View className='index'>
      <Button onClick={this.nameClick}>更改名字</Button>
      <Text>{name}</Text>
      <Child name='857'/>
      </View>
      )
      }
      }

      子组件是这样

      import taro, { Component } from '@tarojs/taro';
      import { View, Text } from '@tarojs/components'

      class Child extends Component {

      render() {
          return (
              <View>
                  <Text>子组件</Text>
                  {this.props.name}
              </View>
          );
      }
      

      }

      export default Child;

      查了好多 最多的说法是更新taro-ui 可是我在node-modules里面没有找到 taro-ui
      我把父组件中引入的Child注释掉 就不报错了
      感觉还是子组件中 哪里不对

      发布在 提 Bug
      六
      六两