小编Muh*_*bal的帖子

通过变量动态导入文件 - 反应原生

我有一个包含组件路径的 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)

ecmascript-6 reactjs react-native metro-bundler

8
推荐指数
1
解决办法
4258
查看次数

使用 TouchableHighlight 更改字体颜色

如何更改按钮的字体颜色,问题是字体颜色看起来不太好,所以每次用户点击按钮时我也需要更改字体颜色。

我的做法:

普通按钮 在此输入图像描述

按下按钮 在此输入图像描述

<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)

react-native

4
推荐指数
1
解决办法
1254
查看次数