react native识别html5,GitHub - soliury/react-native-html-render: A html render for react-native

这篇博客介绍了react-native-html-render库,它是一个用于React Native的HTML渲染组件,特别适合由Markdown生成并压缩的HTML。不过需要注意,其性能并不理想,适用于Noder。库支持img和code渲染,可以设置自定义渲染函数和样式,提供更美观的原生视图。文中还包含了使用示例和API详情。
摘要由CSDN通过智能技术生成

react-native-html-render

A html render for react-native. But don't Suitable for all html. Only Suitable for the html generator by markdown with minify.

Now it used by Noder.

Be careful to use, the performance is not good. If you want to improve the performance, be free to open a issue or send a PR.

Install

npm install react-native-html-render

Futures

Support img and code render.

Can set custom render function and styles.

More beautiful native View.

Demo

687474703a2f2f376c727a666a2e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f736f6c697572796e6f6465722d68746d6c2d72656e6465722e676966

Example

var React = require('react-native')

var HtmlRender = require('react-native-html-render')

var {

Component,

View,

Text,

StyleSheet,

Image

}=React

var styles = StyleSheet.create({

img: {

width: 100,

height: 100

}

})

class HtmlContent extends Component {

_renderNode(node, index, parent, type) {

//Your code here

}

render() {

const sample = "

Hello World
";

return (

value={{sample}}

stylesheet={styles}

renderNode={this._renderNode}

/>

)

}

}

module.exports = HtmlContent

API

value

The value of html content.

stylesheet

Custom styles

onLinkPress

Handle the link click event.

renderNode

Custom render function.

The render function has three arguments.

node: A Object show the node of html.

Struct:

{

name:'text',

text: String,

parent: Object,

type: String

}

or If the node is not a text node:

{

name: String,

attribs: Object,

type: String,

parent: Object

}

index: The index of the node in the parent node.

parent: The parent of the node.

type: Only two types: block or inline.

Mor details:

var blockTagArr = ['div', 'p', 'img', 'address',

'blockquote', 'dir', 'dl',

'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',

'menu', 'ol', 'pre', 'table', 'ul', 'li', 'hr']

var inlineTagArr = ['a', 'abbr', 'b', 'big',

'br', 'cite', 'code', 'em', 'label', 'span', 'strong']

FAQ

More details see Noder.

Licenses

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值