Functions as a rich text editor. The text content must be written between the <richtext> tags. The content format must match the value of the type attribute. The text content must be static content. You are not advised to frequently change text content because frequent changes will deteriorate performance in real-time compilation.
Item | Description |
|---|---|
Applicable devices | Mobile phones, tablets, and telematics devices |
Applicable regions | Global |
In addition to general attributes, the attribute listed in the following table is supported.
Attribute | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
type | html | - | Yes | The HTML format supports standard HTML5 tags and styles and is used for displaying static pages. Rich texts in HTML format are recommended to meet the complex rich text requirements, and text content must be static content. Functions such as data binding and rendering instructions are not supported. |
In addition to common styles, the div style is also supported. However, the height style is invalid. The height and background-color styles cannot be set.
Common events (excluding swipe) are supported. When the type attribute is set to html, events in the following table are also supported.
Event | Parameter | Triggering Condition |
|---|---|---|
start (1070+) | - | Loading starts. |
complete (1070+) | - | Loading is complete. |
<template>
<div class="container">
<div class="page-title-wrap">
<text class="page-title ">{{componentName}}</text>
</div>
<div class="item-container">
<text style="color: #0faeff">richtext type=html</text>
<richtext class="rich-text" type="html" ontouchstart="touchStart" onstart="richtextStart" oncomplete="richTextComplete"
onclick="clickText" onlongpress="longPress" ontouchmove="touchMove" ontouchend="touchEnd">{{htmlText}}</richtext>
</div>
</div>
</template>
<style>
.container {
flex: 1;
flex-direction: column;
}
.container .page-title-wrap {
padding-top: 50px;
padding-bottom: 80px;
justify-content: center;
}
.container .page-title-wrap .page-title {
padding: 30px 40px 30px 40px;
border-color: #bbbbbb;
color: #bbbbbb;
border-bottom-width: 2px;
}
.container .item-container {
margin-bottom: 30px;
margin-right: 30px;
margin-left: 30px;
flex-direction: column;
}
.item-content {
flex-direction: column;
padding-bottom: 30px;
}
.item-title {
padding-top: 50px;
padding-bottom: 20px;
color: #aaaaaa;
}
</style>
<script>
export default {
data: {
componentName: 'richtext component',
htmlText:
`<!DOCTYPE html>
<html lang="en" style="background-color: transparent">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div>
<p class="item-title">h1</p>
<h1>Huawei</h1>
<p class="item-title">h2</p>
<h2>Huawei</h2>
<p class="item-title">h3</p>
<h3>Huawei</h3>
<p class="item-title">h4</p>
<h4>Huawei</h4>
<p class="item-title">h5</p>
<h5>Huawei</h5>
<p class="item-title">h6</p>
<h6>Huawei</h6>
<p class="item-title">img</p>
<div>
<img
src="https://www.huawei.com/Assets/CBG/img/logo.png"
style="width: 100%"
/>
</div>
<p class="item-title">p</p>
<p>Huawei</p>
<p class="item-title">span</p>
<p><span>Huawei</span></p>
<p class="item-title">strong</p>
<p><strong>Huawei</strong></p>
<p class="item-title">del</p>
<p><del>Huawei</del></p>
<p class="item-title">b</p>
<p><b>Huawei</b></p>
<p class="item-title">i</p>
<p><i>Huawei</i></p>
</div>
</body>
</html>
`
},
onInit() {
this.$page.setTitleBar({ text: 'richtext' })
},
richtextStart: function () {
console.log('richtext on Start')
},
richTextComplete: function () {
console.log('richText on Complete')
},
clickText: function () {
console.log('richText on click')
},
longPress: function () {
console.log('richText on longPress')
},
touchStart: function () {
console.log('richText ontouch Start')
},
touchMove: function () {
console.log('richText on touch Move')
},
touchEnd: function () {
console.log('richText on touch End')
}
}
</script> The following figure shows the final effect.

Version | Date | Description |
|---|---|---|
1070 | 2020-05-19 | Added the start and complete events to listen to richtext loading start and completion instances. |