当前位置:网站首页>List rendering in wechat applet
List rendering in wechat applet
2022-06-25 04:03:00 【richest_ qi】
List of articles
Applet project
The main files involved in the code are :
- app.json
- pages/index/index.wxml
- pages/index/index.wxss
- pages/index/index.js

app.json
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarBackgroundColor": "#971a22",
"navigationBarTitleText": " home page ",
"navigationBarTextStyle": "white"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
pages/index/index.wxml
<view class="container">
<swiper class="bannerContainer" autoplay indicator-dots indicator-color="#971a22" indicator-active-color="ivory">
<swiper-item wx:for="{
{bannerList}}" wx:key="id">
<image src="{
{item.pic}}"></image>
</swiper-item>
</swiper>
<scroll-view class="recommendList" enable-flex scroll-x>
<view class="recommendItem" wx:for="{
{recommendList}}" wx:key="id">
<image src="{
{item.picUrl}}"></image>
<view class="title">{
{item.title}}</view>
</view>
</scroll-view>
</view>
pages/index/index.wxss
.bannerContainer image{
width: 100%;
height: 300rpx;
}
.recommendList{
display: flex;
padding: 20rpx;
}
.recommendList image{
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
margin-right: 10rpx;
}
.recommendList .title{
font-size: 26rpx;
display: -webkit-box;
overflow: hidden;
text-overflow:ellipsis;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
pages/index/index.js
Page({
data:{
bannerList:[],
recommendList:[]
},
onLoad(){
this.getBannerList();
this.getRecommendList();
},
getBannerList(){
const result = [
{
pic: "http://p1.music.126.net/N-7H0QxkjcnqNfQo7Prx9g==/109951167582698387.jpg", id: 146917329},
{
pic: "http://p1.music.126.net/CRkjYtGzVn927GVZFNcykQ==/109951167582707134.jpg", id: 146972047},
{
pic: "http://p1.music.126.net/UCpvQwegTjx-_ecHDDrViQ==/109951167583920308.jpg", id: 1958588078},
{
pic: "http://p1.music.126.net/5hxwliN1A-ocfo1y8Rl-LA==/109951167583325800.jpg", id: 146939174},
{
pic: "http://p1.music.126.net/i9A9PG9tvDqkuRekCR8EgQ==/109951167583029047.jpg", id: 1957532468},
{
pic: "http://p1.music.126.net/es8XZbDQWrNjA_VyW7XJeQ==/109951167583025966.jpg", id: 146848766},
{
pic: "http://p1.music.126.net/7YCWTLNpIqzdaYD_WrB6qA==/109951167583039220.jpg", id: 146627102},
{
pic: "http://p1.music.126.net/u2Y1A90S5fh3R4qVhKrIGQ==/109951167582728056.jpg", id: 223052482},
{
pic: "http://p1.music.126.net/Jn1zsklqb_qmPfoJsooJ2Q==/109951167582726188.jpg", id: 1957961053},
{
pic: "http://p1.music.126.net/lsKgZUDW-4C8SRbQciZvmA==/109951167583045066.jpg", id: 1955958008}
]
this.setData({
bannerList:result})
},
getRecommendList(){
const result = [
{
id: 494479726, picUrl: "https://p2.music.126.net/58ox3zVEmosSrdLaKj6x5w==/109951162827155600.jpg", title: " Back shake MV | It turns out that back shaking can also be visualized "},
{
id: 135595185, picUrl: "https://p2.music.126.net/11ZHf0G9FQzWNi-8sFzCmw==/109951164541050373.jpg", title: "Acid Jazz Acid jazz — In Jazz “ Acidic ” The fusion "},
{
id: 114846926, picUrl: "https://p2.music.126.net/GTf1b1G2dAs1SleurIfcJg==/3399689953594431.jpg", title: " The suffixes of song titles are popular science "},
{
id: 113780871, picUrl: "https://p2.music.126.net/qxUWSKhrd1UWME8oAYTMFQ==/109951164497486331.jpg", title: "「Cool Jazz」 Cold Jazz makes you relax "},
{
id: 2962407224, picUrl: "https://p2.music.126.net/NW1GEN3sruiLpT4AZrdDFw==/109951165669533032.jpg", title: "『 British female voice 』 The surviving and independent British rose "},
{
id: 2107922801, picUrl: "https://p2.music.126.net/b--QkIcFfdxz_DryW55ZfA==/109951163165101034.jpg", title: " Acoustooptic aesthetics I Classical soundtrack in classic movies "},
{
id: 78669437, picUrl: "https://p2.music.126.net/AfN_yyi-fQe8POTMKJFjAA==/7957165650297535.jpg", title: " Divine episode in American drama "},
{
id: 3116763088, picUrl: "https://p2.music.126.net/MSom1XSXqt5K9ArZlJ29CQ==/109951164608648583.jpg", title: " The power of music I Secular love songs of the Renaissance "},
{
id: 101354498, picUrl: "https://p2.music.126.net/dmj9iqz8MsD_sCd1xBF0WA==/7918682744429845.jpg", title: " Fashion sports • Essential rhythm "},
{
id: 739403485, picUrl: "https://p2.music.126.net/RPilW2ADtU91CK3qkVPizA==/18720284976441185.jpg", title: " There is sound outside the strings —— Energetic violin "}
]
this.setData({
recommendList:result})
}
})
Summary
Just remember four instructions :
wx:for, Bind an array .wx:key. A unique string or value . Or array elements item A property of , Or*this( here ,item Itself is a unique string or value ).wx:for-item. The variable name of the current element of the default array isitem, have access towx:for-itemReassign the variable name of the current element .wx:for-index. The subscript variable name of the current element of the default array isindex, have access towx:for-indexReassign the subscript variable name of the current element .
Related links
边栏推荐
- uniapp 制作手机app程序, 使用uni.chooseVideo录制视频,视频播放模糊分辨率低的原因
- Work assessment of Biopharmaceutics of Jilin University in March of the 22nd spring -00031
- China's SkyEye found suspicious signals of extraterrestrial civilization. Musk said that the Starship began its orbital test flight in July. Netinfo office: app should not force users to agree to proc
- Development of trading system (VIII) -- Construction of low delay network
- How far is the memory computing integrated chip from popularization? Listen to what practitioners say | collision school x post friction intelligence
- Work assessment of pharmaceutical polymer materials of Jilin University in March of the 22nd spring -00025
- 吴恩达机器学习新课程又来了!旁听免费,小白友好
- Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award
- ICML 2022 | ByteDance AI Lab proposes a multimodal model: x-vlm, learning multi granularity alignment of vision and language
- Windows 2003 64 bit system PHP running error: 1% is not a valid Win32 Application
猜你喜欢

Development of trading system (III) - risk control system

Development of trading system (II) -- market data

NFT Insider #63:The Sandbox与时代杂志达成合作,YGG成立西班牙subDAO
![[harmony OS] [ark UI] basic ETS context operations](/img/fb/a1b8463ba160e6c5aa23d671a0c245.png)
[harmony OS] [ark UI] basic ETS context operations

俄罗斯AIRI研究院等 | SEMA:利用深度迁移学习进行抗原B细胞构象表征预测

Wuenda, the new course of machine learning is coming again! Free auditing, Xiaobai friendly

Trading system development (IV) - trading counter system

【组队学习】SQL编程语言笔记——Task04

代表多样性的彩色 NFT 系列上线 The Sandbox 市场平台

Deveco studio 3.0 editor configuration tips
随机推荐
老叶的祝福
严重的PHP缺陷可导致QNAP NAS 设备遭RCE攻击
Development of trading system (XI) -- Introduction to quickfix
Crawler grabs the data of Douban group
可能是拿反了的原因
web3.eth. Getpendingtransactions() returns null?
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s accesses the Internet of things platform, uploads real-time collected data /tcp transparent transmission (and how to obtain and write Lu
Xidian AI ranked higher than Qingbei in terms of AI majors, and Nantah ranked the first in China in 2022 in terms of soft science majors
OpenSUSE installation pit log
AI quantitative transaction (I) -- Introduction to quantitative transaction
如何使用IDE自动签名调试鸿蒙应用
虽然传统意义上的互联网早已不复存在,但这并不代表互联网早已消失不再
智慧风电:数字孪生 3D 风机智能设备运维
Development of trading system (VII) -- Analysis of trading delay
练习:仿真模拟福彩双色球——中500w巨奖到底有多难?跑跑代码就晓得了。
Lao Ye's blessing
太极图形60行代码实现经典论文,0.7秒搞定泊松盘采样,比Numpy实现快100倍
Why can banana be a random number generator? Because it is the "king of radiation" in the fruit industry
[rust contribution] implement Message Oriented Middleware (6) -client from zero
Do you really need automated testing?