亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

React Native 渲染 html 出現錯誤 => 打開 URL 時出錯

React Native 渲染 html 出現錯誤 => 打開 URL 時出錯

PIPIONE 2024-01-11 17:08:09
我使用 RN、EXPO 和“react-native-render-html”庫來渲染 HTML 源。我想我得到了完美的原始 html,但是當我將它傳遞給像這樣的 HTML 標簽時<HTML html={this.state.html}我遇到這樣的錯誤打開 URL 時出錯:,[錯誤:無法打開 URL:file:///Users/wook/Library/Developer/CoreSimulator/Devices/ 1C8EB2FA-E386-4A53-B136-564DD66A9F86/data/Containers/Bundle/Application/7B6CBBAD- 1F30-48BD-86BB-E536E572854D/Exponent-2.15.3.tar.app/hiddenForm.jsp]我實際上在 stackoverflow 上的類似問題中做了很多事情,但我無法調試它有人可以幫助我嗎?下面是我的代碼import React from 'react';import { StyleSheet, Text, View, Button, TextInput, ScrollView, Dimensions } from 'react-native';import { createAppContainer, ThemeColors } from "react-navigation";import { createStackNavigator } from 'react-navigation-stack';import axios from "axios";import HTML from 'react-native-render-html';class Educlass extends React.Component {  state = {    'html':''  }  componentDidMount() {      const { navigation } = this.props;      const edu_html = navigation.getParam('html');      var myPromise = Promise.resolve(edu_html);      myPromise.then((value) => { this.setState({'html': value} )})  }   render() {    return (      <ScrollView style={styles.container}>        <HTML html={this.state.html} imagesMaxWidth={Dimensions.get('window').width} />        {/* <Text> {this.state.html} </Text> */}        <Text>ad</Text>      </ScrollView>    )  }}const styles = StyleSheet.create({  container: {    flex: 1  }})export default Educlass;我認為我的代碼中有很多問題,因為我是 RN 新手,但感謝解決我的問題(渲染 html)
查看完整描述

1 回答

?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

如果您想從外部 uri 渲染,請使用 WebView 而不是 html 渲染器


npm install --save react-native-webview

import { WebView } from 'react-native-webview';

<WebView source={{html: '<p>Here I am</p>'}} />

<WebView

    source={{ uri: 'https://emir.drh' }}

  />

第一個用于處理內部 html,第二個用于 uri 我希望它有幫助


查看完整回答
反對 回復 2024-01-11
  • 1 回答
  • 0 關注
  • 182 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號