react-native 可以远程加载一个js文件吗?
Can react-native load a js file remotely?
在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”?
我收到错误 The requested URL /index.ios.bundle was not found on this server.
是的,react-native可以远程加载一个js文件。
您应该将捆绑的 js 文件上传到您的服务器并更改 jsCodeLocation
变量。
在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”?
我收到错误 The requested URL /index.ios.bundle was not found on this server.
是的,react-native可以远程加载一个js文件。
您应该将捆绑的 js 文件上传到您的服务器并更改 jsCodeLocation
变量。