<!-- 获取用户名 -->
<view>当前用户名:{{name}}</view>
<view>获取用户头像
<image src="{{path}}" style="height:200rpx;width:200rpx"></image>
</view>
<view bindtap="getUsrName">获取房前用户名:</view>
data: {
message:"大白菜",
name:'',
path:'/img/mryhtx.png'
},
changData:function(){
// 获取数据
console.log(this.data.message);
//修改数据 (错误 后端修改)
// this.data.message="沙雕大白菜";
// 前端正确修改方式
this.setData({message:"大沙雕大白菜"})
},
getUsrName:function(){
var that = this;
console.log('sdf');
// 调用微信接口,获取当前用户信息
wx.getUserInfo({
success: function(res) {
console.log('success',res)
// 获取用户名和头像
that.setData({
// 用户名
name:res.userInfo.nickName,
// 头像
path:res.userInfo.avatarUrl
})
},
file:function(res){
// 调用失败后触发
}
})
}
<button open-type="getUserInfo" bindgetuserinfo="xxxx" >获取用户信息 </button>
xxxx:function(){
wx.getUserInfo({
success: function(res) {
console.log('success',res)
// 获取用户名和头像
},
file:function(res){
// 调用失败后触发
}
})
//手动授权
wx.openSetting(){}
<view bindtap="getLocalPath">{{localPath}}</view>
Page({
data: {
localPath:"当前位置信息"
},
getLocalPath:function(){
var that=this;
wx.chooseLocation({
success:function(res){
that.setData({localPath:res.address});
},
})
}
})
//<text>商品列表展示:</text>
//<view>
//<view wx:for="{{dataList}}">{{index}}-{{item}}</view>
//</view>
<text>商品列表展示:</text>
<view>
<view wx:for="{{dataList}}" wx:for-index="idx" wx:for-item="x">{{idx}}-{{x}}</view>
</view>
<view>
{{userInfo.name}}
{{userInfo.age}}
</view>
<view>
<view wx:for="{{userInfo}}">{{index}}-{{item}}</view>
</view>
// pages/goods/goods.js
Page({
data: {
dataList:[],//列表
userInfo:{//字典
name:'',
age:
}
}
})
<!--pages/publish/publish.wxml-->
<text>pages/publish/publish.wxml</text>
<view bindtap="uploadImage">请上传图片</view>
<view class="container">
<image wx:for="{{imageList}}" src="{{item}}"> </image>
</view>
Page({
data: {
imageList:[]
},
uploadImage:function(){
var that=this;
wx.chooseImage({
count: 9,
siceType:,
sourceType :,
success:function(res){
// that.setData({
// imageList:res.tempFilePaths
// });
//
that.setData({
imageList:that.data.imageList.concat(res.tempFilePaths)
});
}
});
}
})
.container image{
width: 200rpx;
height:200rpx;
padding:5rpx;
}
本文实例讲述了AJAX+Servlet实现的数据处理显示功能。分享给大家供大家参考,具...
CKeditor,以前叫FCKeditor,已经使用过好多年了,功能自然没的说。最近升级到3....
问题:我们在做flex的开发中,如果用到别人搭建好的框架,而别人的server名称往...
idea官方推送了2020.2.4版本的更新,那么大家最关心的问题来了,之前激活idea202...
本文转载自微信公众号「SQL数据库」,作者丶平凡世界 。转载本文请联系开发公众...
本文转载自微信公众号「SH的全栈笔记」,作者SH。转载本文请联系SH的全栈笔记公...
大家好,我是狂聊君。 今天来聊一聊 Mysql 缓存池原理。 提纲附上,话不多说,直...
来源:DeepenStudy 漏洞文件:js.asp % Dimoblog setoblog=newclass_sys oblog.a...
在Flash Player 10.1及以上版本中,adobe新增了全局错误处理程序UncaughtErrorEv...
前言 项目开发中不管是前台还是后台都会遇到烦人的null,数据库表中字段允许空值...