成功构建我的 React Native 应用程序后,我的所有屏幕都没有功能组件。例如,注册和登录函数不会引起服务器的任何响应。下面是我的函数和 eas.json 文件的示例。如果重要的话,我在代码中使用了 ts
{
"build": {
"production": {
"android": {
"buildType": "apk"
},
"env": {
"BASE_URL": "http://my server ip/"
}
}
}
}
export const loginUser = async (user: Login) => {
try {
const response = await http.post(`${process.env.BASE_URL}aaa/aaa/Login`, user);
console.log('response: ', response)
return response;
} catch (error) {
console.log(error);
}
};
我的构建日志中有此警告:
Running "expo doctor"
Running 10 checks on your project...
✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for common project setup issues
✔ Check npm/ yarn versions
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that packages match versions required by installed Expo SDK
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✖ Check that native modules use compatible support package versions for installed Expo SDK
Detailed check results:
Expected package @expo/config-plugins@~7.2.2
Found invalid:
@expo/[email protected]
(for more info, run: npm why @expo/config-plugins)
Expected package @expo/prebuild-config@~6.2.4
Found invalid:
@expo/[email protected]
(for more info, run: npm why @expo/prebuild-config)
Advice: Upgrade dependencies that are using the invalid package versions.
One or more checks failed, indicating possible issues with the project.
Command "expo doctor" failed.
npx -y expo-doctor exited with non-zero code: 1
React Native 本身不包含内置的 HTTP 客户端,但它提供了 fetch API,这是一个用于发出 HTTP 请求的全局函数。 您可以修改AndroidManifest.xml 如果您使用expo,您可以通过添加包来设置usesCleartextTraffic