NervJS / taro-ui

一款基于 Taro 框架开发的多端 UI 组件库
https://taro-ui.taro.zone
MIT License
4.53k stars 758 forks source link

基础的项目, 编译rn, 预览报错 #1675

Closed gaokun closed 11 months ago

gaokun commented 12 months ago

问题描述

taro init了最基础的项目, 只引用了taro-ui的一个button, 编译到h5, weapp都ok

image

但是编译到rn, 预览后报错 image

复现步骤

这是可重现的工程: https://github.com/gaokun/taro-test

pnpm dev:rn --qr 来编译, 然后使用taro-playground来预览的

期望行为

报错信息

系统信息

补充信息

taro-ui-bot[bot] commented 12 months ago

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

robinv8 commented 11 months ago

可以参考 https://github.com/NervJS/taro-ui/issues/1660

gaokun commented 11 months ago

在metro.config.js中添加了上面提到的alias配置, 已解决, thx

const { mergeConfig } = require("metro-config");
const { getMetroConfig } = require("@tarojs/rn-supporter");

module.exports = (async function () {
  return mergeConfig(
    {
      // custom your metro config here
      // https://facebook.github.io/metro/docs/configuration
      resolver: {},
      alias: {
        "~taro-ui/dist": `~taro-ui/rn`,
      },
    },
    await getMetroConfig()
  );
})();