当前位置:网站首页>Possible problems and solutions of using scroll view to implement slider view
Possible problems and solutions of using scroll view to implement slider view
2022-07-01 04:03:00 【richest_ qi】
List of articles
Applet project
The main documents related to 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="indexContainer">
<view class="recommendSongContainer">
<view class="header">
<view class="title"> Recommended song list </view>
<view>
<text class="desc"> Meet your true love song list </text>
<text class="btn">></text>
</view>
</view>
<scroll-view class="recommendSongList" enable-flex scroll-x>
<view class="recommendItem" wx:for="{
{list}}" wx:key="id">
<image src="{
{item.picUrl}}"></image>
<view class="name">{
{item.title}}</view>
</view>
</scroll-view>
</view>
<view class="newSongContainer">
<view class="header">
<view class="title"> New song express </view>
<view>
<text class="desc"> More fresh music, more quick fall </text>
<text class="btn">></text>
</view>
</view>
</view>
<view class="newDiscContainer">
<view class="header">
<view class="title"> New dishes are on the shelves </view>
<view>
<text class="desc"> The new magic disc sounds so popular </text>
<text class="btn">></text>
</view>
</view>
</view>
</view>
pages/index/index.wxss
.indexContainer{
padding: 0 20rpx;
}
.header{
display: flex;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
}
.header .title{
font-weight: bold;
}
.header .desc{
font-size: 24rpx;
color: #333;
padding: 0 20rpx;
}
.header .btn{
font-size: 24rpx;
padding: 0 10rpx;
background: #eee;
color: #888;
border-radius: 6rpx;
}
.recommendSongList{
display: flex;
}
.recommendSongList image{
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
margin-right: 10rpx;
}
.recommendSongList .name{
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:{
list:[]
},
onLoad(){
this.getDataFromServer();
},
getDataFromServer(){
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({
list:result})
}
})
Problem description and solution
- Problem description
scroll-view After horizontal scrolling , Its height is very high , This causes the following elements to almost line up at the bottom of the page , As shown in the figure below .
- resolvent
to scroll-view Set the specified height , Such asheight: 280rpx;, To solve the above problems .
.recommendSongList{
display: flex;
height: 280rpx; /* Appoint scroll-view Height */
}
- Modified effect

Related links
边栏推荐
- Promql select time series
- Procurement intelligence is about to break out, and Alipay'3+2'system helps enterprises build core competitive advantages
- [untitled] Li Kou 496 Next larger element I
- 定了!2022京东全球科技探索者大会之京东云峰会7月13日北京见
- LeetCode 1400. Construct K palindrome strings
- 【TA-霜狼_may-《百人计划》】2.2 模型与材质空间
- [untitled]
- LeetCode 1827. Increment array with minimal operation
- “目标检测“+“视觉理解“实现对输入图像的理解
- [today in history] June 30: von Neumann published the first draft; The semiconductor war in the late 1990s; CBS acquires CNET
猜你喜欢

431. encode n-ary tree as binary tree DFS

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
![[TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation](/img/49/173b1f1f379faa28c503165a300ce0.png)
[TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation

京东智能客服言犀意图体系搭建和意图识别技术介绍

HoloLens2开发环境搭建及部署app

盘点华为云GaussDB(for Redis)六大秒级能力

The programmer's girlfriend gave me a fatigue driving test

分账技术赋能农贸市场,重塑交易管理服务效能

"Target detection" + "visual understanding" realizes the understanding of the input image

【TA-霜狼_may-《百人计划》】1.2.3 MVP矩阵运算
随机推荐
【快捷键】
LetCode 1829. Maximum XOR value per query
318. Maximum word length product
嵌入式系统开发笔记79:为什么要获取本机网卡IP地址
Jenkins自动清理构建历史
【TA-霜狼_may-《百人计划》】1.3纹理的秘密
【TA-霜狼_may-《百人計劃》】1.2.1 向量基礎
不同性能测试工具的并发模式
【JPCS出版】2022年第三届控制理论与应用国际会议(ICoCTA 2022)
409. 最长回文串
【TA-霜狼_may-《百人计划》】2.1 色彩空间
LeetCode 1380. Lucky number in matrix
Valentine's Day is nothing.
线程常用方法与守护线程
类和对象收尾
Analysis and case of pageobject mode
【发送邮件报错】535 Error:authentication failed
431. 将 N 叉树编码为二叉树 DFS
Review column - message queue
NFT: start NFT royalty journey with eip-2981