Created
May 17, 2018 06:58
-
-
Save zhangkn/e1204304f6ab24586a03c0cce7bf22e5 to your computer and use it in GitHub Desktop.
条件渲染
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<view class="userinfo"> | |
<!--1、使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息 //获取数据 --> | |
<!-- /2、使用 open-data 展示用户基本信息。 --> | |
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button> | |
<block wx:else> | |
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> | |
<text class="userinfo-nickname">{{userInfo.nickName}}</text> | |
</block> | |
</view> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({ | |
data: { | |
text: 'Click me get my posts!', | |
motto: helloData, | |
userInfo: {}, | |
hasUserInfo: false, | |
canIUse: wx.canIUse('button.open-type.getUserInfo')//使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息 | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment