Lynx

属性

android-fullscreen-mode

Android
3.4
// @默认值: true
'android-fullscreen-mode'?: boolean;

在横屏时是否进入全屏输入模式,在此模式下键盘和输入框将占据整个屏幕

confirm-type

Android
iOS
Harmony
3.4
// @默认值: 'send'
'confirm-type'?: 'search' | 'send' | 'go' | 'done' | 'next';

确认按钮的类型

disabled

Android
iOS
Harmony
3.5
// @默认值: false
disabled?: boolean;

是否启用交互

input-filter

Android
iOS
Harmony
3.4
// @默认值: undefined
'input-filter'?: string;

过滤输入内容,并以正则表达式的形式进行处理

ios-auto-correct

iOS
3.4
// @默认值: true
'ios-auto-correct'?: boolean;

在 iOS 上自动纠正输入内容

ios-spell-check

iOS
3.4
// @默认值: true
'ios-spell-check'?: boolean;

在 iOS 上检查拼写问题

maxlength

Android
iOS
Harmony
3.4
// @默认值: 140
maxlength?: number;

最大输入长度

placeholder

Android
iOS
Harmony
3.4
placeholder?: string;

占位符

readonly

Android
iOS
Harmony
3.4
// @默认值: false
readonly?: boolean;

只读

show-soft-input-on-focus

Android
iOS
Harmony
3.4
// @默认值: true
'show-soft-input-on-focus'?: boolean;

聚焦时显示软输入键盘

type

Android
iOS
Harmony
3.4
// @默认值: "text"
type?: 'number' | 'text' | 'digit' | 'password' | 'tel' | 'email';

输入内容类型

事件

前端可以绑定相应的事件回调来监听元素的运行时行为,如下所示。

bindblur

Android
iOS
Harmony
3.4
bindblur = (e: InputBlurEvent) => {};
字段类型是否可选默认值平台自版本描述
value字符串
Android
iOS
Harmony
3.4
3.4输入内容

失去焦点

bindconfirm

Android
iOS
Harmony
3.4
bindconfirm = (e: InputConfirmEvent) => {};
字段类型是否可选默认值平台自版本描述
value字符串
Android
iOS
Harmony
3.4
3.4输入内容

确认按钮被点击

bindfocus

Android
iOS
Harmony
3.4
bindfocus = (e: InputFocusEvent) => {};
字段类型是否可选默认值平台自版本描述
value字符串
Android
iOS
Harmony
3.4
3.4输入内容

获得焦点

bindinput

Android
iOS
Harmony
3.4
bindinput = (e: InputInputEvent) => {};
字段类型是否可选默认值平台自版本描述
isComposing布尔值
Android
iOS
Harmony
3.4
3.4是否正在输入
selectionEnd数字
Android
iOS
Harmony
3.4
3.4选中文本的结束位置
selectionStart数字
Android
iOS
Harmony
3.4
3.4选中文本的起始位置
value字符串
Android
iOS
Harmony
3.4
3.4输入内容

输入内容改变

bindselection

Android
iOS
Harmony
3.4
bindselection = (e: InputSelectionEvent) => {};
字段类型是否可选默认值平台自版本描述
selectionEnd数字
Android
iOS
Harmony
3.4
3.4选中文本的结束位置
selectionStart数字
Android
iOS
Harmony
3.4
3.4选中文本的起始位置

输入选中文本改变

方法

前端可以通过 SelectorQuery API 调用组件方法。

blur

Android
iOS
Harmony
3.4

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'blur',
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

释放焦点

focus

Android
iOS
Harmony
3.4

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'focus',
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

请求焦点

getValue

Android
iOS
Harmony
3.4

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'getValue',
      success: Callback<{
        /**
         * 是否正在输入,仅 iOS 支持
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        isComposing: boolean;
        /**
         * 选中文本的结束位置
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionEnd: number;
        /**
         * 选中文本的开始位置
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionStart: number;
        /**
         * 输入内容
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        value: string;
      }>;
      fail: function (res) {},
    })
    .exec();

获取输入内容

setSelectionRange

Android
iOS
Harmony
3.4

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'setSelectionRange',
      params: {
        /**
         * 选中文本的结束位置
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionEnd: number;
        /**
         * 选中文本的开始位置
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        selectionStart: number;
      };
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

设置选中文本范围

setValue

Android
iOS
Harmony
3.4

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'setValue',
      params: {
        /**
         * 输入内容
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @since 3.4
         */
        value: string;
      };
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

设置输入内容

除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。