在我的 React Native 0.67.4 應用程式中,我只注意到某些組件的 js 檔案中有一些紅色標記。紅色標記僅與樣式表有關。這是紅色標記的影像:

這是樣式定義:
const styles = Style.create(
...
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
margin: 30,
backgroundColor: "white",
borderRadius: 20,
padding: 35,
alignItems: "center",
alignContent:"center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
)
以下格式也會出現相同的紅色標記:
<View style={styles.cneteredView, {fontSize:20}}>...</View>
這是devDependency在package.json:
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
},
有沒有辦法擺脫紅色標記?
uj5u.com熱心網友回復:
喲,如果您想使用兩種樣式的類或樣式,這不是您使用它的方式,這就是為什么編輯器會向您顯示錯誤正確的使用方式是這樣的
style={[styles.red, styles.big]}
style={[styles.cneteredView, {fontSize:20}]}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/449968.html
標籤:javascript 反应式 视觉工作室代码
