react-native - react-native 可以远程加载一个js文件吗?

标签 react-native

在Facebook的官方例子中,它说

NSURL *jsCodeLocation;

/**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];

我的问题是我可以远程使用 js 文件,例如“http://www.example.com/index.ios.bundle ”吗?

我收到错误消息在此服务器上找不到请求的 URL/index.ios.bundle。

最佳答案

是的,react-native可以远程加载一个js文件。

您应该将捆绑的 js 文件上传到您的服务器并更改 jsCodeLocation 变量。

关于react-native - react-native 可以远程加载一个js文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30188965/

相关文章:

javascript - 如何在React Native 'Share'函数中设置动态url

javascript - 无法获取组件的复选框以根据另一个组件的状态进行渲染

node.js - React Native错误:您当前正在使用Redux在NODE_ENV ==='production'之外使用缩小代码

reactjs - 如何在 VSCode 的 .js 文件中注释掉 JSX 代码?

android - 如何在 React Native 中同时设置 testID 和 accessibilityLabel?

javascript - Graphql 查询错误!变量已声明但从未使用过

javascript - BlinkID(React-Native)的许可证 key 问题

javascript - 路径和向其传递 Prop 的问题(带有 map 的组件)

ios - 创建用于测试的离线版本 : React Native

javascript - 类型错误 : Cannot read property 'getInitialNotification' of undefined