taro 实战-微信小程序:富文本RichText的使用

关于富文本,taro官方文档是这样的:
[图片上传中...(图片.png-6ef165-1563178647648-0)

然而本人在实际操作中,没有具体的例子,不会使用。也尝试了微信小程序的wxPrase,但是由于我之前文本内容是从上一级页面传递过来的,然后字符限制,被截取了,然后就放弃了wxPrase,又回过头来弄taro的RichText。

其实是可以的。。。

第一步:导入组件

import { View, Text, RichText } from "@tarojs/components";

第二步:使用,把之前存在全局里的内容取出

import Taro, { Component } from "@tarojs/taro";
import { View, Text, RichText } from "@tarojs/components";
import StateStorage from "../../../utils/stateStorage";
import "./index.scss";

export default class Index extends Component {
  config = {
    navigationBarTitleText: "动态"
  };

  render() {
    let { title, contentType, time, contentDetail = "" } = StateStorage.state;

    contentDetail = contentDetail.replace(
      /\
        {title}
        
          
            {contentType == 2 ? "资讯信息" : "节日祝福"}
          
          {time}
        

        
          
        
      
    );
  }
}

你可能感兴趣的:(taro 实战-微信小程序:富文本RichText的使用)