Code Monkey home page Code Monkey logo

wx-wxparese's Introduction

wx-wxParese

示例效果图:

image.png

一、简介及说明

在小程序项目开发中,会遇到富文本编辑的内容,后台返回到小程序端无法解析,这时就需要一个插件来处理。 微信小程序没有提供webview等html解析,原展示类文本没有办法图文并茂的原生展示,wxParse主要目的就是弥补富文本解析空缺的组件。

插件由联盟网站DEV开发,开发者:icindy,最新版本请查看github地址:wxParse

二、 使用方法

1、下载wxParese文件,拷贝wxParse文件夹到自己的小程序项目中。

image.png

2、在项目文件中使用

(1)在需要使用的wxml文件中引入WxParse.wxml

示例:

<!--index.wxml-->
<import src="../../wxParse/wxParse.wxml" />

(2)在当前页对应的js中引入wxParse.js 示例:

//index.js 
const WxParse = require('../../wxParse/wxParse.js');

(3)使用template组件 在刚刚引入的wxml中插入组件,具体插入的位置是需要转换的地方。

示例:

<!--index.wxml-->
<import src="../../wxParse/wxParse.wxml" />
<view class="container">
  <view class='uinn'>
    <template is="wxParse" data="{{wxParseData:article.nodes}}" />
  </view>
</view>

(4)在当前页的js中使用WxParse中的方法

//index.js
const WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    
  }, 
  onLoad: function () {
    let that = this;
    let ceshi = 
    `<div>
			<span>请说出你喜欢的水果?</span>
			<ul>
				<li>苹果</li>
				<li>香蕉</li>
				<li>橙子</li>
			</ul>
		</div>`;
    WxParse.wxParse('article', 'html', ceshi, that, 5); 
  }, 
})

参数说明:

image.png

wx-wxparese's People

Contributors

femocar avatar lemon-yan avatar

Stargazers

Roman avatar krystal_H avatar 郭攀 avatar  avatar 彭旭 avatar duduchong avatar Mr.Hao avatar 逆水寒 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.