第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

react-native-webview 加載本地 HTML 文件但得到純文本

react-native-webview 加載本地 HTML 文件但得到純文本

FFIVE 2022-06-16 10:50:22
我嘗試加載 HTML 文件取決于其他 .js 文件。所以我寫了這樣的代碼,但是在 webview 中得到了純文本。render = () => {    let source;    if (__DEV__) {      source = require('./vendor/Editor/index.html');    } else {      source =        Platform.OS === 'ios'          ? require('./vendor/Editor/index.html')          : {uri: 'file:///android_asset/vendor/Editor/index.html'};    }    return (      <WebView        startInLoadingState        source={source}        onMessage={this.handleMessage}        automaticallyAdjustContentInsets={false}        style={[          AppStyles.container,          styles.container,          {height: this.state.visibleHeight},        ]}      />    );  };我像這樣簡化代碼,但它也不起作用。  render = () => {    setTimeout(() => {      this.webview.injectJavaScript(        'window.ReactNativeWebView.postMessage(document.body.innerHTML)',      );    }, 3000);    return (      <WebView        source={require('./vendor/GrEditor/index.html')}        onMessage={e => console.log('e: ', e)}      />    );  };對不起語法不好。
查看完整描述

1 回答

?
料青山看我應如是

TA貢獻1772條經(jīng)驗 獲得超8個贊

要在 android 中加載本地 html 文件,即使在開發(fā)模式下也需要使用 android 資產路徑。所以它會是這樣的:

let source = Platform.OS === 'ios'
          ? require('./vendor/Editor/index.html')
          : {uri: 'file:///android_asset/vendor/Editor/index.html'};

將您的供應商文件夾復制到 android.assets 文件夾(project_folder\android\app\src\main\assets)中。
這是供您參考的鏈接:https ://github.com/react-native-community/react-native-webview/blob/master/docs/Guide.md#loading-local-html-files


查看完整回答
反對 回復 2022-06-16
  • 1 回答
  • 0 關注
  • 416 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號