导航

    Taro 社区

    Taro

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

    15683637638_p

    @15683637638_p

    0
    声望
    3
    帖子
    361
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    15683637638_p 关注

    15683637638_p 发布的帖子

    • RE: TypeError: (0, _taroRn.useState) is not a function

      刚刚在群里面问了,这个功能需要RN的版本>=0.59.0才支持

      发布在 React Native
      1
      15683637638_p
    • TypeError: (0, _taroRn.useState) is not a function

      Taro版本:v1.3.25
      代码:

      export default (props) => {
        const activityDesc = props[activityDescKey];
      
        const [showIntroduce, setShowIntroduce] = useState(false);
        const showIntro = () => setShowIntroduce((prev) => !prev);
        ....
      }
      

      上面这个组件在weapp和h5里面都正常运行,但是在rn中运行时报错

      TypeError: (0, _taroRn.useState) is not a function
      

      貌似taro没有在rn中对hooks进行处理?

      发布在 React Native
      1
      15683637638_p
    • RE: Image图片的引入

      先导入要使用的图片

      import yourImg from './imgpath/imgName.png';
      

      再使用图片

      <Image src={yourImg}/>
      

      如果你的图片名称是通过计算得出了,请使用require.context

      const imgContext = require.context('./imgPath/', false, /\.(png|jpg|gif)$/);
      const computeImgName = ()=>{....}; //返回的图片名称确保在/imgPath下,名称前确保加上'./'
      <Image src={imgContext(computeImgName())} />
      

      taro在打包时,会将小图片直接转换成base64的字符串,直接嵌入到html中,只有大图片,才会输出到/static/images目录下。

      发布在 H5
      1
      15683637638_p