You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
833 B
48 lines
833 B
3 years ago
|
// components/search/searchbar.js
|
||
|
Component({
|
||
|
/**
|
||
|
* 组件的属性列表
|
||
|
*/
|
||
|
properties: {
|
||
|
placeholder: {
|
||
|
type: String,
|
||
|
value: '',
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 组件的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
inputValue: ''
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 组件的方法列表
|
||
|
*/
|
||
|
methods: {
|
||
|
// 用户输入触发
|
||
|
handleInput: function (e) {
|
||
|
this.setData({
|
||
|
inputValue: e.detail.value
|
||
|
})
|
||
|
},
|
||
|
// 点击清空输入框icon
|
||
|
handleDeleteClick: function () {
|
||
|
this.setData({
|
||
|
inputValue: ''
|
||
|
})
|
||
|
},
|
||
|
// 点击取消触发
|
||
|
handleTextbtnClick() {
|
||
|
// 触发父组件中的方法
|
||
|
this.setData({
|
||
|
inputValue: ''
|
||
|
})
|
||
|
},
|
||
|
// 用户点击确定触发
|
||
|
handleConfirm() {
|
||
|
this.triggerEvent('handleSearch', this.data.inputValue)
|
||
|
}
|
||
|
}
|
||
|
})
|