![](/img/trans.png)
[英]Attempted import error: 'styles' is not exported from './styles.scss' (imported as 'styles')
[英]Attempted import error: 'styles' is not exported from './styles'
我正在嘗試從style.js
文件中導入 styles 並且該文件包含以下代碼
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'
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.