智能小程序 Ray 开发实践——基础内容组件 Progress 和 RichText 介绍

Progress

进度条。

导入

import { Progress } from '@ray-js/ray';

属性说明

属性类型默认值必填说明
percentnumber百分比 0~100
showInfobooleanfalse在进度条右侧显示百分比
borderRadiusnumber/string0圆角大小,默认为 rpx
fontSizenumber/string16右侧百分比字体大小,默认为 px
strokeWidthnumber/string6进度条线的宽度,默认为 rpx
activeColorstring#007aff已选择的进度条的颜色
backgroundColorstringrgba(0,0,0,.04)未选择的进度条的颜色
activebooleanfalse进度条从左往右的动画
activeModestringbackwardsbackwards: 动画从头播;forwards:动画从上次结束点接着播

示例代码

import React from 'react';
import { View, Progress } from '@ray-js/components';
 
export default function () {
  return (
    <View>
      <View className="progress-box">
        <Progress percent={20} showInfo strokeWidth={3}/>
      </View>
 
      <View className="progress-box">
        <Progress percent={60} active strokeWidth={3} />
      </View>
 
      <View className="progress-box">
        <Progress percent={80} activeColor="#10AEFF" active strokeWidth={3} />
      </View>
    </View>
  );
}

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。 

RichText

富文本。

导入

import { RichText } from '@ray-js/ray';

属性说明

属性名类型默认值必填说明支持平台
nodesarray/string[]节点列表/HTML StringWeb

nodes

现支持两种节点,通过 type 来区分,分别是元素节点和文本节点,默认是元素节点,在富文本区域里显示的 HTML 节点。

元素节点:type = node
属性说明类型必填备注
name标签名string支持部分受信任的 HTML 节点
attrs属性object支持部分受信任的属性,遵循 Pascal 命名法
children子节点列表array结构和 nodes 一致
文本节点:type = text
属性说明类型必填备注
text文本string支持 entities

受信任的 HTML 节点及属性

全局支持 class 和 style 属性,不支持 id 属性

节点属性
a
abbr
address
article
aside
b
bdi
bdodir
big
blockquote
br
caption
center
cite
code
colspan,width
colgroupspan,width
dd
del
div
dl
dt
em
fieldset
font
footer
h1
h2
h3
h4
h5
h6
header
hr
i
imgalt,src,height,width
ins
label
legend
li
mark
nav
olstart,type
p
pre
q
rt
ruby
s
section
small
span
strong
sub
sup
tablewidth
tbody
tdcolspan,height,rowspan,width
tfoot
thcolspan,height,rowspan,width
thead
trcolspan,height,rowspan,width
tt
u
ul
iframe
pre

示例代码

  • style.less
.item-wrap {
  margin: 16px 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--ty-native-checkbox-border);
}
 
.btn-line + .btn-line {
  margin-top: 10px;
}

基本使用
import React from 'react';
import { View, RichText } from '@ray-js/components';
 
import './style.less';
 
export default function () {
  return (
    <View>
      <View className="item-wrap">
        <RichText nodes='<div><h1>Title</h1><p>Life is <i>like</i> a box of <b style="color: red">chocolates</b>.</p></div>' />
      </View>
      <View className="item-wrap">
        <RichText
          nodes={[
            {
              name: 'div',
              attrs: {
                name: 'outer',
              },
              children: [
                {
                  type: 'text',
                  text: 'You never know what you are gonna get.',
                },
              ],
            },
          ]}
        />
      </View>
    </View>
  );
}

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。 

  • 19
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
Richtext组件是一种富文本组件,适用于Android和iOS平台。它可以用于实现内联或与内联块组合,并支持嵌套的<span>标签,以及样式的继承和覆盖。因此,可以将Richtext视为具有更强大用法的更通用的<text>组件。通过设置Richtext组件的selectable属性,可以实现长按选中文本内容的效果。这样,用户可以将光标放在文本内容上,长按选择并复制文本。 富文本的作用是可以在一个文本中包含不同的颜色、不同的字号、不同的背景颜色的文本。通过使用rich-text属性,可以实现对文本的样式进行更细致的控制,达到更好的呈现效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [weex-richtext:适用于AndroidiOS的Weex RichText组件](https://download.csdn.net/download/weixin_42126399/18226837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [微信小程序常用组件实战](https://blog.csdn.net/chengqiuming/article/details/126747735)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [小程序开发组件rich-text(富文本)](https://blog.csdn.net/JackJia2015/article/details/86300651)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoT砖家涂拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值