Zusammenfassung der Benutzeroberfläche und der Containerkomponenten des WeChat Mini-Programms
1. Zusammenfassung und Übersicht
2. Containerkomponenten
2.1 Komponente Container (Ansicht)
2.2 Scroll-Ansicht Container (Scroll-Ansicht)
2.3 Slider-Ansicht Container (Swiper)
1. Zusammenfassung und Übersicht
1.1 Übersichtsdiagramm der UI-Komponenten
1.2 Übersicht
UI des Mini Programm Eine Komponente ist eine Reihe von Tags, die eine Benutzeroberfläche definieren, ähnlich wie HTML-Tags. Ein vollständiger Benutzerreaktionsprozess: Ereignisauslösung – > UI-Komponente empfängt Ereignis – > löst js-Funktion aus, um auf Ereignis zu reagieren – > 2. Containerkomponente
2.1 Containerkomponente (Ansicht)
(1) Zusammenfassung
(2) Beispiel
Rendering
page.wxml
page.wxss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <view>
<text class = "row-view-title" >水平布局:</text>
<view class = "flex-wrp-row" >
<view class = "flex-item-red" hover= "true" hover- class = "hover-style" ><text class = "color-text" >red</text></view>
<view class = "flex-item-green" hover= "true" hover- class = "hover-style" ><text class = "color-text" >green</text></view>
<view class = "flex-item-blue" hover= "true" hover- class = "hover-style" ><text class = "color-text" >blue</text></view>
</view>
</view>
<view>
<text class = "column-view-title" >垂直布局:</text>
<view class = "flex-wrp-column" >
<view class = "flex-item-red" hover= "true" hover- class = "hover-style" ><text class = "color-text" >red</text></view>
<view class = "flex-item-green" hover= "true" hover- class = "hover-style" ><text class = "color-text" >green</text></view>
<view class = "flex-item-blue" hover= "true" hover- class = "hover-style" ><text class = "color-text" >blue</text></view>
</view>
</view>
|
Nach dem Login kopieren
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | .flex-item-red{
background-color: red;
height: 200rpx;
width: 200rpx;
text-align: center;
line-height: 200rpx;
}
.flex-item-green{
background-color: green;
height: 200rpx;
width: 200rpx;
text-align: center;
line-height: 200rpx
}
.flex-item-blue{
background-color: blue;
height: 200rpx;
width: 200rpx;
text-align: center;
line-height: 200rpx
}
.flex-wrp-row{
flex-direction: row;
display: flex;
margin-left: 10rpx;
margin-top: 20rpx;
}
.flex-wrp-column{
flex-direction: column;
display: flex;
margin-left: 10rpx;
margin-top: 20rpx;
}
.color-text{
color: snow;
font-family: 'Times New Roman', Times, serif;
font-weight: bold;
}
.hover-style{
background-color: black;
}
.row-view-title,.column-view-title{
margin-left: 20rpx;
font-family: 'Times New Roman', Times, serif;
font-weight: bold;
}
|
Nach dem Login kopieren
2.2 Scroll-View-Container (Scroll-View)
(1) Zusammenfassung
(2) Beispiel
Rendering:
page.wxml
page.wxss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <view>
<text>水平滚动布局</text>
</view>
<view class = "x-view" >
<scroll-view class = "scroll-view-x" scroll-x= "true" bindscrolltoupper= "scrollXToUpper" bindscrolltolower= "scrollXToLower" bindscroll= "scroll" scroll-left= "0" scroll-into-view= "{{green}}" >
<view id= "green" class = "x_green" ></view>
<view id= "red" class = "x_red" ></view>
<view id= "yellow" class = "x_yellow" ></view>
<view id= "blue" class = "x_blue" ></view>
</scroll-view>
</view>
<view>
<text>垂直滚动布局</text>
</view>
<view class = "y-view" >
<scroll-view class = "scroll-view-y" scroll-y= "true" bindscrolltoupper= "scrollYToUpper" bindscrolltolower= "scrollYToLower" bindscroll= "scroll" scroll-top= "0" scroll-into-view= "{{green}}" >
<view id= "green" class = "y_green" ></view>
<view id= "red" class = "y_red" ></view>
<view id= "yellow" class = "y_yellow" ></view>
<view id= "blue" class = "y_blue" ></view>
</scroll-view>
</view>
|
Nach dem Login kopieren
page.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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | .x_green{
background-color: green;
width: 500rpx;
height: 300rpx;
display: inline-flex;
}
.x_red{
background-color: red;
width: 500rpx;
height: 300rpx;
display: inline-flex;
}
.x_blue{
background-color: blue;
width: 500rpx;
height: 300rpx;
display: inline-flex;
}
.x_yellow{
background-color: yellow;
width: 500rpx;
height: 300rpx;
display: inline-flex;
}
.y_green{
background-color: green;
width: 100%;
height: 300rpx;
}
.y_red{
background-color: red;
width: 100%;
height: 300rpx;
}
.y_yellow{
background-color: yellow;
width: 100%;
height: 300rpx;
}
.y_blue{
background-color: blue;
width: 100%;
height: 300rpx;
}
.scroll-view-x{
display: flex;
white-space: nowrap;
width: 100%;
margin-bottom: 20px;
margin-top: 10px;
height: 300rpx;
}
.scroll-view-y{
height: 400rpx;
}
|
Nach dem Login kopieren
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 30 31 32 33 | var app = getApp()
Page({
data:{
toview:'red',
},
scrollXToUpper: function (){
console.log('scrollXToUpper')
},
scrollXToLower: function (){
console.log('scrollXToLower')
},
scrollYToUpper: function (){
console.log('scrollYToUpper')
},
scrollYToLower: function (){
console.log('scrollYToLower')
},
scroll: function (){
console.log( "scroll" )
},
onLoad: function () {
console.log('onLoad')
var that = this
},
})
|
Nach dem Login kopieren
2.3 Slider-Ansichtscontainer (Swiper)
(1) Zusammenfassung
(2) Beispiel
Rendering:
page.wxml
Seite .js
1 2 3 4 5 6 7 8 | <swiper data-current= "0" current= "0" bindchange= "itemChangeFunc" circular= "true" indicator-dots= "{{indicatorDots}}"
autoplay= "{{autoplay}}" interval= "{{interval}}" duration= "{{duration}}" >
<block wx: for = "{{imgUrls}}" wx:key= "swiperkeys" >
<swiper-item>
<image src= "{{item}}" class = "slide-image" width= "355" height= "150" />
</swiper-item>
</block>
</swiper>
|
Nach dem Login kopieren
Vielen Dank fürs Lesen, ich hoffe, es kann allen helfen, vielen Dank für Ihre Unterstützung dieser Website!
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 30 31 32 | Page({
data: {
imgUrls: [
'/image/wechat.png',
'http:
'http:
'http:
],
indicatorDots: true,
autoplay: true,
interval: 3000,
duration: 1000,
current:1,
},
durationChange: function (e) {
this.setData({
duration: e.detail.value
})
},
durationChange: function (e) {
this.setData({
duration: e.detail.value
})
},
itemChangeFunc: function (e){
console.log(e.detail)
}
})
|
Nach dem Login kopieren
Weitere Artikel zur WeChat-Applet-Benutzeroberfläche und Containerkomponenten finden Sie auf der chinesischen PHP-Website!