我正在尝试通过使用React Native Web库在Web中使用React Native组件。
但是当这样做时,我的DOM元素具有很多内联样式,这使它看起来很杂乱,我们如何才能在转译过程中摆脱多余的样式。
类似这样的东西
我们甚至可以摆脱这个转换后的内联CSS。
这就是我在这里使用的React Native组件的样子
import React from "react";
import { View, Text, Platform, StyleSheet } from "react-native";
const instructions = Platform.select({
ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
android:
"Double tap R on your keyboard to reload,\n" +
"Shake or press menu button for dev menu",
web: "Your browser will automatically refresh as soon as you save the file."
});
const HomeScreen = () => {
return (
<View >
<Text>
Welcome to React Native Web universal app!
</Text>
<Text>
This component is shared between web and react environment. To see how
it works, just edit the HomeScreen.js
</Text>
<Text>{instructions}</Text>
</View>
);
};
/*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
}
});*/
export default HomeScreen;
将RNW更新为0.11.4后,DOM看起来更干净,更精简,但可以消除它们。