简体   繁体   English

如何在本机中解决模块名称冲突

[英]How to resolve module name conflict in react native

I have two module with the exact same name that belongs to two different apps, these two module are functionally quite similar except for the styling. 我有两个模块具有完全相同的名称,属于两个不同的应用程序,这两个模块在功能上非常相似,除了样式。 I am creating a master component and try to import these two different module based on what app I am currently in. 我正在创建一个主组件,并尝试根据我当前的应用程序导入这两个不同的模块。

I wonder if there is a way to conditionally import the module that I don't have to hard code a name space for the module, like module_app1 and module_app2 but instead to do 我想知道是否有办法有条件地导入模块,我没有硬编码模块的名称空间,如module_app1module_app2 ,而是做

if (cond) {
    import module from 'path1';
} else {
    import module from 'path2';
}

I use 'as'. 我用'as'。 Example: 例:

import Actions from '../actions';
import { Actions as Navigator } from 'react-native-router-flux';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入冲突两个模块反应原生 - import conflict two module react native react-native 如何解决“无法解析模块...”错误? - How to solve "Unable to resolve module..." error with react-native? React Native TypeScript:无法解析模块(但它存在) - React Native TypeScript: Unable to resolve module (but it exists) 无法解决模块“事件” React-Native - Unable to resolve module “events” React-Native 在本机反应中不断收到“无法解析模块” - Keep getting "Unable to resolve module" in react native 无法解析模块。/SignIn In React Native 应用程序 - Unable to resolve module ./SignIn In React Native app 无法解析模块`scheduler/tracing` react native - Unable to resolve module `scheduler/tracing` react native 反应本地映像“无法解析模块” - React native image “Unable to resolve module” 如何解决“动画:不支持`useNativeDriver`,因为缺少本机动画模块。” 在反应导航? - How to resolve "Animated: `useNativeDriver` is not supported because the native animated module is missing." in react-navigation? React Native 导入错误:无法使用 .bin 解析模块(如何导入某种类型的文件?) - React Native importing error: unable to resolve module with .bin (how to import a certain type of file?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM