这篇文章主要介绍了微信小程序开发实例详解的相关资料,需要的朋友可以参考下
简单搞了一下,吼吼~:
js:业务处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | var app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {name:'汗青',
desc: "前端的春天来了!\n 前端要烂大街了!!" ,
avatarUrl: "http://img2.3lian.com/2014/gif/10/9/25.jpg" }
},
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
console.log('onLoad')
var that = this
app.getUserInfo( function (userInfo){
that.setData({
userInfo:userInfo
})
that.update()
})
}
})
|
Salin selepas log masuk
wxml:创建布局
1 2 3 4 5 6 7 8 9 10 11 12 | <!--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>
|
Salin selepas log masuk
wxss:设置样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | .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;
}
|
Salin selepas log masuk
演示截图

小程序组件Demo演示截图

Atas ialah kandungan terperinci 微信小程序快速开发简单入门教程. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!