Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize rich-text support for Rich text in Mini Program

Shulou Source: shulou.com Published: 2022-06-01 00:28:55 10月01日 Update

This article mainly explains the "Mini Program how to achieve rich-text rich text support", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Mini Program how to achieve rich-text rich text support" bar!

Analysis of Mini Program Rich text

At present, Mini Program uses a lot of rich text solutions, one is the rich-text component of Mini Program, and the other is wxPrase.

The principle of wxPrase is to parse all the original html tags into Mini Program components, so that both event control and scalability are good, but it is not very good for inline rendering and multi-rendering.

Wechat's built-in rich-text component just makes up for the performance shortcomings of wxPrase inline rendering and multi-rendering, but it does not have high support for some custom tags and will block all events of the element. Although it supports direct parsing of html strings, the performance is not as good as binding json strings directly.

Rich-text demo demo given on the official website:

Page ({data: {nodes: [{name: 'div', attrs: {class:' div_class', style: 'line-height: 60px; color: red;'}, children: [{type:' text', text: 'Hello Worldwaters'}]}}, tap () {console.log ('tap')}})

Rich-text-parser is an json format that converts html strings into a json format that can be parsed by rich-text components, can customize extension tags, and supports modification of html styles (including img tags) within rich-text components.

How to use it:

Npm I rich-text-parser-S-- productionimport parser from 'rich-text-parser'Page ({data: {html: `

Manjusri Forest House and Mountain House, designed by Mr. Yu Mingjin of Pullman Resort in Lijiang, are online celebrity accommodation in the ancient city of Lijiang. In 2017, they were rated as the country's 100 "most beautiful accommodation" and the "365 beds" worth sleeping in 2017.

Both shops are located halfway up the north gate of the ancient city, leaning against Castle Peak and overlooking the panoramic view of the ancient city.

Manjushri Forest House 2 rooms, Manjushri Mountain Room 6 rooms, a total of 8 rooms. There are landscape rooms with panoramic views of the ancient city of Lijiang, rooms with big beds covered with sunshine, and duplex rooms with garden views.

The room is equipped according to the five-star standard, Kohler bathroom, goose down quilt, brand latex mattress, high-end toiletries, etc., providing free washing machine, dryer, self-help kitchen and other supporting services.

Each room is at a moderate distance, creating a more private and comfortable space experience for all tenants! In addition, the landlord can provide one-to-one butler service, accept all tenants' advice on eating, drinking and entertainment, as well as various convenient activities with discounts!

Lijiang Manjusri designer network celebrity residential big bed room

Lijiang Manjusri designer network celebrity residential big bed room

Manjusri designer network celebrity twin room in Lijiang

Manjusri designer network celebrity big bed room in Lijiang (panoramic view of the ancient city)

Manjusri designer network celebrity big bed room in Lijiang (panoramic view of the ancient city)

Manjusri designer network celebrity duplex empty room in Lijiang (panoramic view of the ancient city)

Lijiang Manjusri designer network celebrity residential villa east courtyard

Dining Room

Public area

Public area

Public area-balcony

Manjusri designers in Lijiang, online celebrities living in Tangchi Villa West Courtyard

Lijiang Manjusri designer network celebrity residential villa east courtyard

Store Information:

Wifi covered, 24-hour hot water, hairdryer, disposable products

Electric blanket, fireplace, one-on-one butler service, etc.

Merchant contact number:

Add: 26 Beimenpo Xuantian Xiang, Gucheng District, Lijiang City, Yunnan Province

Tel: 15099 128722

`, html2: []}, onLoad () {const {html} = this.data / / defines the special tags to be parsed. If value is left empty, the default is div parser.definedCustomTag ({figure: 'div', figcaption:'}) const nodes = parser.getRichTextJson (html) console.log (nodes) this.setData ({html2: nodes.children})})

Effect drawing and data structure:

Thank you for your reading, the above is the "Mini Program how to achieve rich-text support for rich text" content, after the study of this article, I believe you have a deeper understanding of how Mini Program to achieve rich-text support for rich text, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Lijiang Manjusri designers programs ancient city support accommodation text tags components panoramic observable villa area aspect learning service one-on-one Lijiang ancient city Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Linux Microsoft Huawei