css样式中榜单列表中的数值显示不正确不知道哪里的问题
来源:1-1 导学
weixin_慕虎2325182
2020-07-05
<template>
<div class="song-list">
<ul>
<li @click="selectList(item,index)" v-for="(item,index) in songs" :key="index" class="item">
<div class="rank" v-show="rank">
<span :class="getRankCls(index)">{{getRankText(index)}}</span>
</div>
<div class="content">
<h2 class="name">{{item.name}}</h2>
<p class="desc">{{item.singer}}·{{item.album}}</p>
</div>
</li>
</ul>
</div>
</template>
<script type="text/ecmascript-6">
export default {
props: {
songs: {
type: Array,
default: []
},
rank: {
type: Boolean,
default: false
}
},
methods: {
selectList(item, index) {
this.$emit("select", item, index);
},
//前三名的图标
getRankCls(index) {
//判断index小于等于2的时候,就进入icon,否则为text
if (index <= 2) {
return `icon icon${index}`;
} else {
return "text";
}
},
getRankText(index) {
//下标大于2 的话 就下标加1
if (index > 2) index + 1;
}
}
};
</script>
<style scoped lang="stylus" rel="stylesheet/stylus">
@import '~style/style/variable';
@import '~style/style/mixin';
.song-list {
.item {
display: flex;
align-items: center;
box-sizing: border-box;
text-align: left;
height: 64px;
font-size: $font-size-medium;
.rank {
flex: 0 0 25px;
width: 25px;
height: 100%;
margin-right: 30px;
text-align: center;
.icon {
display: inline-block;
width: 25px;
height: 24px;
background-size: 25px 24px;
margin-top: 10px;
&.icon0 {
bg-image('first');
}
&.icon1 {
bg-image('second');
}
&.icon2 {
bg-image('third');
}
}
.text {
color: $color-theme;
font-size: $font-size-large;
}
}
.content {
flex: 1;
line-height: 20px;
overflow: hidden;
margin-left: 39px;
.name {
no-wrap();
color: $color-text;
}
.desc {
no-wrap();
margin-top: 4px;
color: $color-text-d;
}
}
}
}
</style>
写回答
1回答
-
ustbhuangyi
2020-07-05
为啥我 clone 你的项目安装依赖总是失败,你那边能正常安装依赖吗
00
相似问题