... <看更多>
「react native webview html asset」的推薦目錄:
- 關於react native webview html asset 在 [教學] 偽react-native app - WebView - 看板Ajax - 批踢踢實業坊 的評價
- 關於react native webview html asset 在 React-native WebView: Load html and js from assets folder 的評價
- 關於react native webview html asset 在 No way to load a local HTML file in the webview on Android 的評價
- 關於react native webview html asset 在 React Native, Android and Loading embeded HTML pages in ... 的評價
- 關於react native webview html asset 在 Can't navigate in React Native Webview if using local html file 的評價
- 關於react native webview html asset 在 Devmenu Github 的評價
- 關於react native webview html asset 在 Login Screen Native React Github Template - Mobili a Genova 的評價
react native webview html asset 在 No way to load a local HTML file in the webview on Android 的推薦與評價
Might be because we have the html in the assets folder? I've got it working using the following on ios/android in debug and release builds with ... ... <看更多>
react native webview html asset 在 React Native, Android and Loading embeded HTML pages in ... 的推薦與評價
Loading of a local html file in a webview in React Native is as simple as this. <WebView source={{ uri: '../assets/generic.html' }} />. First ... ... <看更多>
react native webview html asset 在 Can't navigate in React Native Webview if using local html file 的推薦與評價
Put html, CSS and js files in the assets folder inside android\app\src\main · Install and import {WebView} inside App.js · Whenever you click on a link like ... ... <看更多>
react native webview html asset 在 Devmenu Github 的推薦與評價
In simple terms, WebView is a component that used to load webpages in your React Native app. That being said, if you enjoy a game and you have ... ... <看更多>
react native webview html asset 在 Login Screen Native React Github Template - Mobili a Genova 的推薦與評價
Search: React Native Login Screen Template Github. ... to native platform components, as opposed to using JavaScript/HTML and a web view. ... <看更多>
react native webview html asset 在 [教學] 偽react-native app - WebView - 看板Ajax - 批踢踢實業坊 的推薦與評價
最近在學react跟react-native發現:
react可以用來寫web apps。
react-native可以用來寫Android、iOS、甚至Win 10 apps。
但兩者的UI components是不能直接交換使用的囧
這樣好像就不能寫一次JS code,直接輸出三種apps: web, Android, iOS。
後來發現react-native有提供WebView component,
它相當於在app內建一個瀏覽器,可以讀取HTML, CSS, JS,
就可以用來讀取react web app bundle!
不過還是強調,
WebView這種作法並不像是使用react-native UI components有native的效能,
我稱之"偽"react-native apps。
它的好處是可以偷懶:寫好一個react web app,
不用改寫UI成為react-native UI,就能轉換成Android, iOS apps。
或許對轉換一些小web apps還頗實用。用途請自行取捨。
以下步驟在教如何把react web app轉成偽react-native apps:
(在此假設你的OS是Linux、
react-native Android開發環境已照Ref. [1]建立)
# 安裝react與react-native apps生成工具:
npm install -g create-react-app react-native
# 建立react app:
create-react-app myapp
cd myapp
# 修改bundle裡URLs的啟始路徑[2],加入下面這行至package.json:
"homepage": "."
# 此步可考慮執行npm start驗證你的web app是否正常。
# 產生bundle:
npm run build
# 會輸出到build資料夾。
cd ..
# 建立react-native app:
react-native init AwesomeProject
cd AwesomeProject
# 產生assets資料夾:
mkdir -p android/app/src/main/assets
# react-native會把assets資料夾的檔案一並包入bundle。
# 把react的bundle所在資料夾build,連結到assets底下:
cd ..
ln -s myapp/build AwesomeProject/android/app/src/main/assets
cd AwesomeProject
# 修改index.android.js的render,使用WebView讀build/index.html:
<View>
<WebView style={{ backgroundColor: "blue", height: 200 }}
source={{uri: 'file:///android_asset/build/index.html'}}
scalesPageToFit={true} />
</View>
# 參照assets的uri要以"file:///android_asset"開頭[3]。
# 啟動Android emulator:
android avd
# 執行react-native app:
react-native run-android
# 觀查emulator有沒有啟動Android app,畫面應該跟web app一樣。
Refs:
[1]
https://facebook.github.io/react-native/docs/getting-started.html#content
[2]
https://stackoverflow.com/questions/38565538/create-react-app-css-and-js-path/
[3] https://github.com/facebook/react-native/issues/505
--
楞嚴咒(附注音):
https://1drv.ms/1c0YbNt
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.115.73.148
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1472559745.A.991.html
... <看更多>