它看起来像一个简单的问题,有一个简单的答案,即npm install @react-native-community/checkbox,但它不起作用。我有一个错误,说包有一个依赖的反应-本机窗口,所以我也下载了这个软件包,导致我的问题解决不了。
我真的不明白为什么会这样..。
这是我的package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/checkbox": "^0.5.6",
"expo": "~39.0.2",
"expo-status-bar": "~1.0.2",
"moviedb-promise": "^3.1.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-image": "^4.0.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.2.tar.gz",
"react-native-web": "~0.13.12",
"react-native-windows": "^1.0.0",
"react-tinder-card": "^1.3.1"
},
"devDependencies": {
"@babel/core": "~7.9.0"
},
"private": true
}编辑

这是我的代码:
import React from 'react'
import { View, Text } from 'react-native';
import CheckBoxSetting from './CheckBoxSetting';
import PressableSetting from './PressableSetting'
import SwitchSetting from './SwitchSetting';
function SettingItemFactory () {
this.createSettingItem = function (name, type, initState) {
let settingItem = <Text/>;
switch(type){
case 'pressable':
settingItem = <PressableSetting title={name}/>;
break;
case 'switch':
settingItem = <SwitchSetting name={name} state={initState}/>
break;
case 'check':
settingItem = <CheckBoxSetting name={name} state={initState}/>
break;
default:
settingItem = <PressableSetting title={name} />;
}
return settingItem;
}
}
export default SettingItemFactory;
import React from 'react'
import {View, Text, ImagePropTypes} from 'react-native'
import CheckBox from '@react-native-community/checkbox'
const CheckBoxSetting = (props) => {
return (
<View>
<Text>
{props.name}
</Text>
</View>
)
}
export default CheckBoxSetting;发布于 2020-12-02 02:34:41
在最初文章的评论中给出了答案:从现在起,图书馆不受世博的支持。谢谢Tushar!
发布于 2021-04-17 02:05:27
如果您在您的react本机项目中使用expo,那么expo提供了一个可以利用的Checkbox组件,并且它似乎使用了与react本机CheckBox组件相同的API。:)
发布于 2021-07-06 10:49:19
在世博会上不支持。在react本机CLI中,确保完成了链接并进行了pod安装。
https://stackoverflow.com/questions/65061884
复制相似问题