我正在尝试从style.js
文件导入样式,该文件包含以下代码
const export styles = {
border: 'solid',
textAlign : 'center',
boxShadow : '2px 2px'
}
但是在文件
中显示了下面的错误'export' is not allowed as a variable declaration name.
但是当我添加export
关键字时,如下所示代码
const styles = {
border: 'solid',
textAlign : 'center',
boxShadow : '2px 2px'
}
export default styles;
试图导入我的组件为
import * as styles from "./styles";
<div style={styles.styles}>
Style
</div>
我得到下面的错误
Attempted import error: 'styles' is not exported from './styles'.
如何解决?
用这个方法style.js
import { StyleSheet } from 'react-native';
export const styles = StyleSheet.create({
});
试图导入我的组件为
import styles from "./styles";
尝试默认导出
const styles = {
border: 'solid',
textAlign : 'center',
boxShadow : '2px 2px'
}
export default styles;
我尝试了下面的代码,它为我工作
export const externalStyles = {
color : 'red',
backgroundColor: 'green'
}