类: Label
约 619 字大约 2 分钟
2024-05-03
构建固件和导入到JS
Label 类由 lv 模块提供:
import { Label } from 'lv'简介
标签控件
显示文本的标签控件
该类是对 LVGL Widget
lv_label_t的封装,具体用法请参考 LVGL 文档
继承自 Obj,拥有 Obj 的全部属性、方法和事件。
示例:
import * as lv from "lv"
const obj = new lv.Label(lv.screen())类属性
属性 font
类型: string
访问: 可读, 可写
设置或获取标签字体。内置字体命名为 "m" + 字号(如 "m14" 表示 Montserrat 14, 实际可用字号取决于 lv_conf.h 中的 LV_FONT_MONTSERRAT_* 配置); 也可使用 lv.loadFont() 加载的自定义字体名称。
读取时,内置字体返回对应的名称,其他情况返回 null;写入未知字体名时设置失败。
属性 text
类型: number
访问: 可读, 可写
该属性是对 LVGL C API
lv_label_get_text,lv_label_set_text的封装, 具体用法请参考 LVGL文档
属性 textStatic
访问: 只写
该属性是对 LVGL C API
lv_label_set_text_static的封装, 具体用法请参考 LVGL文档
属性 longMode
类型: number
访问: 可读, 可写
该属性是对 LVGL C API
lv_label_get_long_mode,lv_label_set_long_mode的封装, 具体用法请参考 LVGL文档
属性 textSelectionStart
类型: number
访问: 可读, 可写
该属性是对 LVGL C API
lv_label_get_text_selection_start,lv_label_set_text_selection_start的封装, 具体用法请参考 LVGL文档
属性 textSelectionEnd
类型: number
访问: 可读, 可写
该属性是对 LVGL C API
lv_label_get_text_selection_end,lv_label_set_text_selection_end的封装, 具体用法请参考 LVGL文档
类方法
方法 insText
原型: insText ()
该方法是对 LVGL C API
lv_label_ins_text的封装,具体用法请参考 LVGL文档
返回值:
undefined
方法 cutText
原型: cutText ()
该方法是对 LVGL C API
lv_label_cut_text的封装,具体用法请参考 LVGL文档
返回值:
undefined
