我试图实现react-native-show-hide-toggle-box来获取电子盒,但是每当我运行该项目时,我都会得到一个错误: (无法从“ node_modules / react-native-show-hide-toggle-box / ToggleBox.js”中解析模块“ ./ToggleBoxStyle”)
这是我第一次使用此模块,我无法通过它。
我检查了包含同一目录中的ToogleBoxStyles和ToogleBox文件的节点模块,但是当我进入ToogleBox时,它显示以下行: 从“ ./ToggleBoxStyle”导入样式
所以当我安装它时如何使它工作 npm我本机显示隐藏切换框-保存
默认导入的基本导入向我显示错误。
import React from 'react';
import { LayoutAnimation, View, Text, StatusBar, ScrollView, Picker, StyleSheet } from 'react-native'
import ToggleBox from 'react-native-show-hide-toggle-box'
export default class TimeSlot extends React.Component {
render() {
return (
<ScrollView style={styles.container}>
<Toggle label='Show me something' value='asd' style={{backgroundColor: '#ddd', borderBottomWidth: 1}}>
<View style={{height: 300, alignItems: 'center', justifyContent: 'center', backgroundColor: '#eee'}}>
<Text>Hello, how are you?</Text>
</View>
</Toggle>
</ScrollView>
)
}
}
From ToogleBox.js
import React, { PropTypes } from 'react'
import { Text, View, Image, TouchableWithoutFeedback, Animated} from 'react-native'
// external libs
import Icon from 'react-native-vector-icons/MaterialIcons'
// styles
import styles from './ToggleBoxStyle'
How to make the above thing work for me?
答案 0 :(得分:0)
出于某些原因,这对我很有效。我用import { ToggleBox } from 'react-native
代替了import { ToggleBox } from 'react-native-show-hide-toggle-box'
。