Files
doodle-mini/miniprogram/components/word-input/word-input.ts
T

53 lines
1.1 KiB
TypeScript

Component({
options: {
// multipleSlots: true, // 在组件定义时的选项中启用多slot支持
},
/**
* 组件的属性列表
*/
properties: {
width: {
type: String,
value: '', // 按钮宽度
},
placeholder: {
type: String,
value: '请输入文字',
},
},
/**
* 组件的初始数据
*/
data: {
},
lifetimes: {
attached() {
(this as any).value = '';
},
},
/**
* 组件的方法列表
*/
methods: {
onInput(e: WechatMiniprogram.Input) {
let { value } = e.detail;
value = value.replace(/\s/g, '');
if (value.length > 0) {
(this as any).value = value;
}
},
onConfirm() {
const value = (this as any).value;
if (value.length > 0) {
this.triggerEvent('onConfirm', { value });
}
},
// onTap() {
// this.triggerEvent('onTap', { words: (this as any).words });
// },
},
});