import { dispatchEvent } from 'bsl-core/app/EventMessage'; import C from 'bsl-mp/app/Component'; import { setTimeout } from 'bsl-mp/app/Scheduler'; import Event from 'bsl-mp/typings/event'; import * as Export from './export'; const state = { }; class Instance extends C { constructor() { super(state, { placeholder: String, placeholderStyle: String, placeholderClass: { type: String, value: '' }, disabled: Boolean, maxlength: { type: Number, value: 140 }, cursorSpacing: Number, autoFocus: Boolean, focus: Boolean, alwaysEmbed: String, confirmHold: Boolean, cursor: Number, selectionStart: { type: Number, value: -1 }, selectionEnd: { type: Number, value: -1 }, adjustPosition: { type: Boolean, value: true }, holdKeyboard: Number, confirmType: { type: String, value: 'done' }, helper: Object, autoHeight: Boolean, showConfirmBar: Boolean, fixed: Boolean }); } public options = { styleIsolation: 'apply-shared' } protected externalClasses = ['wrap-cls']; public bindChange(e: Event.InputChange) { if (this.properties.helper) { this.properties.helper.onChange(e.detail.value); } else { console.warn('input组件缺少helper'); } this.triggerEvent('change', e.detail); } public bindFocus(e: Event.InputChange) { if (this.properties.helper) { dispatchEvent(Export.foucsEventKey, this.properties.helper.id); } this.triggerEvent('focus', e.detail); } public bindBlur(e: Event.InputChange) { if (this.properties.helper) { // 防止formitem的清除图标消失得太快 wx.nextTick(() => { dispatchEvent(Export.blurEventKey, this.properties.helper!.id); }); } this.triggerEvent('blur', e.detail); } public bindConfirm(e: Event.InputChange) { this.triggerEvent('confirm', e.detail); } public bindKeyboardheightchange(e: Event.InputChange) { this.triggerEvent('keyboardheightchange', e.detail); } } Component(new Instance().init());