rich-text

富文本。 属性说明 注意

  • app-nvue 平台 nodes 属性只支持使用 Array 类型
  • 支付宝小程序 nodes 属性只支持使用 Array 类型。 html-parser 转换。 支持默认事件,包括:click、touchstart、touchmove、touchcancel、touchend、longpress。 nodes 属性推荐使用 Array 类型,由于组件会将 String 类型转换为 Array 类型,因而性能会有所下降。

    nodes

    现支持两种节点,通过 type 来区分,分别是元素节点和文本节点,默认是元素节点,在富文本区域里显示的 HTML 节点。 元素节点:type = node 文本节点:type = text

    受信任的HTML节点及属性

    不支持id属性示例
    1. <template> <view class="content"> <page-head :title="title"></page-head> <view class="uni-padding-wrap"> <view class="uni-title uni-common-mt"> 数组类型 <text>\nnodes属性为Array</text> </view> <view class="uni-common-mt" style="background:#FFF; padding:20rpx;"> <rich-text :nodes="nodes"></rich-text> </view> <view class="uni-title uni-common-mt"> 字符串类型 <text>\nnodes属性为String</text> </view> <view class="uni-common-mt" style="background:#FFF; padding:20rpx;"> <rich-text :nodes="strings"></rich-text> </view> </view> </view></template>
    1. export default { data() { return { nodes: [{ name: 'div', attrs: { class: 'div-class', style: 'line-height: 60px; color: red; text-align:center;' }, children: [{ type: 'text', text: 'Hello&nbsp;uni-app!' }] }], strings: '<div style="text-align:center;"><img src="https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/uni@2x.png"/></div>' } }}
    Tips
  • uni-app插件市场搜索uparse插件使用。
  • -

在 GitHub 上编辑此页面!