- input输入查询第一次正常,第二次页面标签全部消失?
<view class="serach"> <image src="{{imageUrl}}/image/search.png" /> <input class="sear-view" model:value="{{search_text}}" bindinput="searchFun" placeholder="搜索线路、站点" /> <view class="null"></view> </view> <view class="sear_body" wx:elif="{{search_text!=''}}"> <block wx:if="{{searchList.bllist.length>0}}"> <!-- 线路 --> <view class="if_type"> <view class="sear_type">线路</view> <block wx:if="{{searchList.bllist.length>3}}"> <block wx:for="{{searchList.bllist}}" wx:key="blid"> <view class="sear_list" bindtap="blTap" data-blid="{{item.blid}}" data-blname="{{item.blname}}"> <block wx:if="{{index<=3}}"> <view id="blid{{item.blid}}"><image src="{{imageUrl}}/image/bus.png" /><text>{{item.blname}}</text></view> </block> <block wx:if="{{index>3}}"> <view id="blid{{item.blid}}" style="display: {{!blBlean?'none':''}}" > <image src="{{imageUrl}}/image/bus.png" /><text>{{item.blname}}</text></view> </block> </view> </block> <view class="zkOrSq black" bindtap="zkOrSq" data-bl="0"><text>{{!blBlean?'展开':'收起'}}</text></view> </block> <block wx:if="{{searchList.bllist.length<=3}}"> <block wx:for="{{searchList.bllist}}" wx:key="blid"> <view class="sear_list" bindtap="blTap" data-blid="{{item.blid}}" data-blname="{{item.blname}}"> <view id="blid{{item.blid}}"><image src="{{imageUrl}}/image/bus.png" /><text>{{item.blname}}</text></view> </view> </block> </block> </view> </block> <block wx:if="{{searchList.stlist.length>0}}"> <!-- 站点 --> <view class="if_type"> <view class="sear_type">站点</view> <block wx:if="{{searchList.stlist.length>3}}"> <block wx:for="{{searchList.stlist}}" wx:key="stid"> <view class="sear_list" bindtap="stTap" data-stid="{{item.stid}}" data-stname="{{item.bsname}}"> <block wx:if="{{index<=3}}"> <view id="stid{{item.stid}}"><image src="{{imageUrl}}/image/site.png" /><text>{{item.bsname}}</text></view> </block> <block wx:if="{{index>3}}"> <view id="stid{{item.stid}}" style="display: {{!stBlean?'none':''}}" > <image src="{{imageUrl}}/image/site.png" /><text>{{item.bsname}}</text></view> </block> </view> </block> <view class="zkOrSq black" bindtap="zkOrSq" data-bl="1"><text>{{!stBlean?'展开':'收起'}}</text></view> </block> <block wx:if="{{searchList.stlist.length<=3}}"> <block wx:for="{{searchList.stlist}}" wx:key="stid" > <view class="sear_list" bindtap="stTap" data-stid="{{item.stid}}" data-stname="{{item.bsname}}"> <view id="stid{{item.stid}}"><image src="{{imageUrl}}/image/site.png" /><text>{{item.bsname}}</text></view> </view> </block> </block> </view> </block> <block wx:if="{{searchList.adlist.length>0}}"> <!-- 目的地 <view class="if_type" wx:if="{{sear_type2==true}}"> <view class="sear_type">到这去</view> <view class="sear_list" wx:for="{{searchList}}" wx:key="*this"> <view wx:if="{{item.type==2}}"><image src="{{imageUrl}}/image/path/hiPath.png" /><text>{{item.content}}</text></view> </view> </view> --> </block> </view> 以上是wxml代码 以下是js代码 searchFun(){ console.log("456456"); var that=this; let val=that.data.search_text; getList(); async function getList(){ console.log("123123"); let data = await request(getApp().globalData.globalUrl+"labus/datashare/QS_QUERY",{"stquery":val}); console.log(data); if (data.data && data.data.bllist.length > 0 || data.data.stlist.length > 0) { // 处理搜索结果不为空的情况 that.setData({ searchList: data.data, blBlean: false, stBlean: false }); } else { // 处理搜索结果为空的情况 that.setData({ searchList: [], blBlean: false, // 根据实际情况设置是否显示无数据的提示或其他操作 stBlean: false }); } } }, 第一次搜索正常显示,删除第一次的搜索文字,第二次输入时请求正常返回数据,但是wxml标签全部消失,变成空白页
2023-07-20 - 使用input输入查询第一次有结果,第二次输入直接页面空白,怎么回事?
<view class="serach"> <image src="{{imageUrl}}/image/search.png" /> <input class="sear-view" model:value="{{search_text}}" bindinput="searchFun" placeholder="搜索线路、站点" /> <view class="null"></view> </view> </view> searchFun(){ var that=this; let val=that.data.search_text; getList(); async function getList(){ let data = await request(getApp().globalData.globalUrl+"labus/datashare/QS_QUERY",{"stquery":val}); console.log(data); that.setData({ searchList:data.data, blBlean:false, stBlean:false }) } }, 这是第一次输入“佛”显示查询结果 [图片] 这是删除input值重新输入“佛”变成空白页面 [图片]
2023-07-20