Page({
data: {
inputValue: ''
},
getSearch(e) {
console.log(e.detail.value)
},
bindKeyInput: function (e) {
this.setData({
inputValue: e.detail.value
})
},
})
<view class="searchRoot">
<input class="searchInput"
bindinput="getSearch"
placeholder="搜索菜品"></input>
<image class="searchImg" bindtap="goSearch" src="/image/sousuo.png"></image>
</view>
<view class="page-section">
<view class="weui-cells__title">实时获取输入值:{{inputValue}}</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<input class="weui-input" maxlength="10" bindinput="bindKeyInput" placeholder="输入同步到view中"/>
</view>
</view>
</view>