<view wx:if="{{userInfo.userPhoto!=null}}" class="logo" id="userinfo">
<image bindtap="ViewImage" data-src="{{userInfo.userPhoto}}" mode="widthFix" src="{{userInfo.userPhoto}}"></image>
</view>
<view wx:elif="{{userInfo.userPhoto===null}}" class="logo" id="userinfo">
<image bindtap="ViewImages" mode="widthFix" src="/images/setPhoto.jpg"></image>
</view>
一个小程序小白,为什么这样 判断的时候进入不了呢 百思不得其解,数据对象为空时,用wxml定位,显示的仍然是第一个view,希望各位大神能给解解疑惑。

用取反吧 wx:if="{{userInfo.userPhoto}}" wx:elif="{{!userInfo.userPhoto}}"已解决!
data中定义一个数据变量接收数据!
将属性值获取到后,使用三元运算符赋值给定义的变量,
view中通过判断变量进行显示。
this.setData({path:userInfo.userPhoto.trim()!=''?userInfo.userPhoto:null})