0
foo.js(代碼塊從陣營母語樣板):陣營母語:模塊化造型
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
什麼是從一個不同的文件bar.js宣佈新的風格的最佳方式是什麼?
1)添加一個新的屬性到styles
?
//import styles from 'foo.js'
styles.forNewComponent = {
fontSize: 30,
};
2)或者創建新的StyleSheet
obj?
const StylesforNewComponent = StyleSheet.create({
fontSize: 30,
});
當使用1)方法和console.log(styles);
輸出是:
Object {container: 3, welcome: 4, instructions: 5, forNewComponent: Object}
爲什麼forNewComponent
的值是一個對象,但其他性能都ID
我做錯了?我會有性能問題嗎?
感謝您的解釋! – Edgar
不客氣。樂意效勞 ) –