<view class=“search-bar”>
<view class=“v-input-q”><input type=“text” class=“input-q” focus="{{searchFocused}}"/></view>
<button class=“btn btn-search” bindtap=“openSearch”><text class=“glyphicon glyphicon-search”></text></button>
<button class=“btn btn-location”><text class=“glyphicon glyphicon-map-marker”></text></button>
</view>
Page({
data: {
searchFocused:false
},
openSearch:function(){
console.log(“button tap, focus input”);
this.setData({searchFocused:true});
},
//…
});
点击input能聚焦。
但是点旁边的button,focus={{true}} 没法自动聚焦, console能看到 “button tap, focus input” 输出
开发工具里测试是OK的,但是真机预览时没法聚焦。
=======================
Android 7.1.1
微信 6.3.31