nrz 3af67f5565 [new feature] Search: 新增搜索组件 (#321)
[new feature] Search: 新增搜索组件
2018-07-03 11:20:24 +08:00

68 lines
1.3 KiB
JavaScript

Component({
externalClasses: ['search-class', 'input-class', 'cancel-class'],
properties: {
cancelText: {
type: String,
value: '取消'
},
disabled: {
type: Boolean,
value: false
},
focus: {
type: Boolean,
value: false
},
keyword: {
type: String,
value: ''
},
show: {
type: Array,
value: ['icon', 'cancel']
},
placeholder: {
type: String,
value: '请输入查询关键字',
observer(newVal) {
this.setData({
inputWidth: `${(newVal.length * 14) + 45}px`
});
}
},
useCancel: {
type: Boolean
},
searchStyle: String,
cancelStyle: String,
inputStyle: String,
},
data: {
inputWidth: 'auto'
},
methods: {
blur() {
this.triggerEvent('blur');
},
clearInput() {
this.setData({
focus: true
});
this.triggerEvent('change', { value: '' });
},
cancelSearch() {
this.triggerEvent('cancel');
},
focus() {
this.triggerEvent('focus');
},
inputChange(e) {
this._inputvalue = e.detail.value;
this.triggerEvent('change', { value: e.detail.value });
},
search(e) {
this.triggerEvent('search', { value: e.detail.value });
}
}
});