Text

版本要求:
@ray-js/ray≥0.5.10

描述

文本内容组件,用于显示文本信息。

属性

属性类型必填默认值说明
userSelectboolean否false文本是否可选
selectable已废弃boolean否-文本是否可选
↳ 请使用 userSelect 替代

示例代码

基础用法

import React from 'react';
import { View, Text } from '@ray-js/ray';

export default function Demo() {
  return (
    <View style={{ padding: 20 }}>
      <Text style={{ fontSize: 16, color: '#333' }}>这是一段普通文本</Text>
    </View>
  );
}

可选择文本

import React from 'react';
import { View, Text } from '@ray-js/ray';

export default function Demo() {
  return (
    <View style={{ padding: 20 }}>
      <Text userSelect style={{ fontSize: 16, color: '#007aff', lineHeight: '24px' }}>
        这段文字设置了 userSelect,长按可以选中并复制。
      </Text>
      <Text style={{ fontSize: 16, marginTop: 12, color: '#999' }}>
        这段文字未设置 userSelect,无法选中。
      </Text>
    </View>
  );
}