微信小程序 案例 学习 1
来源:互联网 发布:帝国cms 使用程序代码 编辑:程序博客网 时间:2024/05/29 06:45
//index.js//获取应用实例var app = getApp()Page({ data: { welcome: '欢迎来到微信小程序', userimage:'获取域名', chouseImages:'上传图片', userInfo: {}, tempFilePaths:'' }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, bindUserImage:function(){ wx.navigateTo({ url:'../users/images' }) }, chooseimage:function(){ var _this = this wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { _this.setData({ tempFilePaths:res.tempFilePaths }) } }) }, onLoad: function () { console.log('onLoad') var that = this //调用应用实例的方法获取全局数据 app.getUserInfo(function(userInfo){ //更新数据 that.setData({ userInfo:userInfo }) console.log(userInfo); }) }})index.wxml<!--index.wxml--><view class="container"> <view bindtap="bindViewTap" class="userinfo"> <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> <text class="userinfo-nickname">{{userInfo.nickName}}</text> </view> <view class="usermotto"> <text class="user-motto">{{welcome}}</text> </view> <view bindtap="bindUserImage" class="userimage"> <text class="user-image">{{userimage}}</text> </view> <button class="userimage" bindtap="chooseimage">{{chouseImages}}</button><image src="{{tempFilePaths}}" /></view>/**index.wxss**/.userinfo { display: flex; flex-direction: column; align-items: center;}.userinfo-avatar { width: 128rpx; height: 128rpx; margin: 20rpx; border-radius: 50%;}.userinfo-nickname { color: #aaa;}.usermotto { margin-top: 100px;}.userimage{ margin-top: 20px; color: #aaa;}.userimage img{ width: 10px; height: 10px;}
0 0
- 微信小程序 案例 学习 1
- 微信小程序案例 大全
- 微信小程序登录案例
- springmvc程序案例1
- 微信小程序入门教程+案例demo
- 微信小程序入门教程+案例demo
- 微信小程序入门教程+案例demo
- 微信小程序入门教程+案例demo
- 微信小程序源码案例大全
- JavaScript案例学习1
- Lucene6.1学习案例
- 学习案例1
- NSGA_II学习案例1
- 经典的程序案例1
- 案例1判断闰年程序
- javaScript学习DOM案例1
- 微信小程序学习1
- [微信小程序]知识总结及案例汇总
- bzoj 2038 莫队算法
- 彻底弄懂 Http 缓存机制 - 基于缓存策略三要素分解法
- C语言日记——递归
- MyBatis的简单的ResultMaps映射
- 判定程序属于计算密集和访存密集的方法
- 微信小程序 案例 学习 1
- Android Dialog样式activity并去掉标题
- Glide库加载图片
- leetcode-119. Pascal's Triangle II
- Jquery中$.get(),$.post(),$.ajax(),$.getJSON()对比
- 二维数组查找
- 逐浪CMS后台微信公众号如何配置参数
- iOS集成支付宝支付
- 电信行业软件的十大特点