微信小程序開發(fā)實例詳解
“小程序”破解IDE + Demo:https://github.com/gavinkwoe/weapp-ide-crack.git
資源匯總:https://github.com/Aufree/awesome-wechat-weapp
官方簡易教程·MINA:http://wxopen.notedown.cn/
Hello小程序 - 非官方:http://www.helloxcx.com
微信應用號開發(fā)教程:https://my.oschina.net/wwnick/blog/750055
資源來自網(wǎng)絡,拿走不謝!
簡單搞了一下,吼吼~:
js:業(yè)務處理
//index.js //獲取應用實例 var app = getApp() Page({ data: { motto: 'Hello World', userInfo: {name:'汗青', desc:"前端的春天來了!\n 前端要爛大街了??!", avatarUrl:"http://img2.3lian.com/2014/gif/10/9/25.jpg"} }, //事件處理函數(shù) bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function () { console.log('onLoad') var that = this //調用應用實例的方法獲取全局數(shù)據(jù) app.getUserInfo(function(userInfo){ //更新數(shù)據(jù) that.setData({ userInfo:userInfo }) that.update() }) } })
wxml:創(chuàng)建布局
<!--index.wxml--> <view class="container"> <view bindtap="bindViewTap" class="userinfo"> <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> <text class="userinfo-name">{{userInfo.name}}</text> <text class="userinfo-desc">{{userInfo.desc}}</text> </view> <view class="usermotto"> <text class="user-motto">{{motto}}</text> </view> </view>
wxss:設置樣式
/**index.wxss**/ .userinfo { display: flex; flex-direction: column; align-items: center; } .userinfo-avatar { width: 128rpx; height: 128rpx; margin: 20rpx; border-radius: 50%; } .userinfo-name { color: #aaa; font-size: 30rpx; margin: 30rpx; } .userinfo-desc { color: #f00; font-size: 50rpx; line-height: 70rpx; } .usermotto { margin-top: 200px; }
演示截圖
小程序組件Demo演示截圖
以上就是微信小程序的簡單實例,希望能幫助開始學習微信開發(fā)的朋友,謝謝大家對本站的支持!