admin

在taro3.0中使用wxParse
wxParse 主要是用于富文本解析准备wxParse 文件下载github地址: https://github....
扫描右侧二维码阅读全文
11
2020/08

在taro3.0中使用wxParse

wxParse 主要是用于富文本解析

准备

wxParse 文件下载


github地址: https://github.com/icindy/wxParse

使用

  • 复制wxparse 代码到文件夹

image.png

  • 新建index.js、index.wxml文件
// index.js
import Fuck from './wxParse'

Component({
    properties: {
        html: {
            type: String,
            value: '',
        },
    },
    observers: {
        html: function () {
            Fuck.wxParse('wxParseData', 'html', this.properties.html, this)
        },
    },
})


// index.wxml
<import src="./wxParse.wxml" />
<template
    is="wxParse"
    data="{{wxParseData:wxParseData.nodes}}"
    key="{{Math.random()}}"
/>
  • 在页面文件新建 index.config.js 引入wxparse组件
export default {
    usingComponents: {
        wxparse: './wxparse/index', // 书写第三方组件的相对路径
    },
}
  • 使用
<wxparse html={`<p>模拟html代码</p>`} key={Math.random()} />
Last modification:August 12th, 2020 at 11:36 am

Leave a Comment