此处以 search 组件为例:
<van-search
placeholder="搜索 XXXX"
use-action-slot
:value="searchValue"
@change="handleSearchChange"
@click="handleSearch">
<view
slot="action"
@click="handleSearch">搜索
</view>
</van-search>
export default {
data () {
return {
searchValue: ''
}
},
methods: {
handleSearchChange (event) {
this.searchValue= event.mp.detail
},
handleSearch () {
console.log(this.searchValue)
}
}
}
因为不支持双向数据绑定,所以用 change 事件改变值,我试过把 event
写在 handleSearch
里,但不是预期值。
评论区