0

我在尝试在 React Native Web 中加载最基本的自定义映射时遇到问题。自定义样式在应用程序中加载得很好,但不是 Web。使用此处建议的 babel loader hack 的最新版本。我正在使用 UI Kitten docs for v5.x 中建议的默认映射

我的代码如下所示:

import * as eva from '@eva-design/eva'
import * as mapping from '../styles/mapping.json'
import { myTheme } from '../styles/light-theme'

export default function App(): React.ReactElement {
    return <>
            <ApplicationProvider {...eva} theme={myTheme} customMapping={mapping}>
             ...
            </ApplicationProvider>
        </>
}
4

2 回答 2

1

我尝试使用空白 repo 进行复制,它工作正常,所以一次一行我发现我的导入不正确(babel 无法读取?)。

代替:

import * as mapping from '../styles/mapping.json'

应该:

import {default as mapping} from '../styles/mapping.json'

UIKitten 文档中建议了正确的方法,所以我认为这不会发生在很多人身上,但可能会对其他人有所帮助,因为如果有人长时间使用 App 模拟器并且不检查 Web 直到之后。

于 2020-10-17T09:36:02.517 回答
0

这是我将自定义映射与 ts 文件一起使用的方式:custom-mapping.ts

export const customMapping: any = {
    components: {
        CircleButton: {
            meta:{...},
            appearances: {...}
    }
    }
}

并像这样导入它:

...
import {customMapping} from '../custom-mapping';

<ApplicationProvider
     ...
     customMapping={{...eva.mapping, ...customMapping}}
   >
      {children}
</ApplicationProvider>
于 2022-01-19T15:24:43.640 回答