我有一个包含组件路径的 path.json 文件
// path.json
{
"main": "./login/index.js",
"paths": [
{
"name": "login",
"path": "./login/index.js",
"image": ""
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想在 react native 中动态加载'./login/index.js'文件并呈现这个特定文件
我目前的实施
const MyComponent = createLazyContainer(() => {
const componentPath = PathJson.main; // ./login/index.js
return import(`${componentPath}`); //import error here @ line 7
});
export default MyComponent;
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
第 7 行的无效调用:import("" + componentPath)
如何更改按钮的字体颜色,问题是字体颜色看起来不太好,所以每次用户点击按钮时我也需要更改字体颜色。
我的做法:
<TouchableHighlight
underlayColor="#E5E6EA"
onPress={onOpen2}
style={{
fontFamily: "AktivGroteskCorp",
paddingLeft: 15,
paddingRight: 15,
borderRadius: 25.5,
flexDirection: "row",
justifyContent: "center",
marginBottom: 15,
width: vw * 67.2,
height: vw * 13.6,
alignItems: "center",
alignSelf: "center",
borderColor: "#E5E6EA",
borderWidth: 1,
}}
>
<Text
style={{
color: "#ffffff",
fontWeight: "bold",
fontSize: 16,
textAlign: "center",
alignSelf: "center",
}}
>
LOG IN
</Text>
</TouchableHighlight>
Run Code Online (Sandbox Code Playgroud)