微信小程序開發(fā)實(shí)例詳解
“小程序”破解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
微信應(yīng)用號(hào)開發(fā)教程:https://my.oschina.net/wwnick/blog/750055
資源來自網(wǎng)絡(luò),拿走不謝!
簡單搞了一下,吼吼~:
js:業(yè)務(wù)處理
//index.js
//獲取應(yīng)用實(shí)例
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
//調(diào)用應(yīng)用實(shí)例的方法獲取全局?jǐn)?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:設(shè)置樣式
/**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演示截圖

以上就是微信小程序的簡單實(shí)例,希望能幫助開始學(xué)習(xí)微信開發(fā)的朋友,謝謝大家對(duì)本站的支持!
相關(guān)文章
微信小程序(應(yīng)用號(hào))組件詳細(xì)介紹
這篇文章主要介紹了微信小程序(應(yīng)用號(hào))組件詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2016-09-09

