当前位置:首页 > uni-app

好看的uniapp列表

2026-02-06 11:05:07uni-app

设计美观的UniApp列表

使用uni-list组件可以快速创建基础列表样式,搭配uni-icons和自定义样式提升视觉效果。示例代码:

<template>
  <uni-list>
    <uni-list-item 
      v-for="(item, index) in list" 
      :key="index"
      :title="item.title" 
      :note="item.desc"
      clickable
      @click="handleClick(item)"
    >
      <template v-slot:header>
        <uni-icons type="contact" size="24"></uni-icons>
      </template>
    </uni-list-item>
  </uni-list>
</template>

卡片式列表布局

通过view和CSS阴影效果实现卡片式设计,适合商品展示等场景:

<template>
  <view class="card-list">
    <view 
      v-for="(item, index) in list" 
      :key="index" 
      class="card-item"
      @click="handleClick(item)"
    >
      <image :src="item.image" mode="aspectFill"></image>
      <text class="title">{{item.title}}</text>
      <text class="price">¥{{item.price}}</text>
    </view>
  </view>
</template>

<style>
.card-list {
  display: flex;
  flex-wrap: wrap;
  padding: 10px;
}
.card-item {
  width: 48%;
  margin: 1%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  overflow: hidden;
}
</style>

瀑布流布局实现

结合CSS多列布局实现瀑布流效果,适合图片类内容展示:

<template>
  <view class="waterfall">
    <view 
      v-for="(item, index) in list" 
      :key="index"
      class="item"
      :style="{height: item.height + 'px'}"
    >
      <image :src="item.image"></image>
      <text>{{item.title}}</text>
    </view>
  </view>
</template>

<style>
.waterfall {
  column-count: 2;
  column-gap: 10px;
  padding: 10px;
}
.item {
  break-inside: avoid;
  margin-bottom: 10px;
}
</style>

交互增强列表

添加滑动操作、加载动画等交互效果:

<template>
  <uni-swipe-action>
    <uni-swipe-action-item 
      v-for="(item, index) in list"
      :key="index"
      :right-options="options"
    >
      <uni-list-item 
        :title="item.title"
        showArrow
      />
    </uni-swipe-action-item>
  </uni-swipe-action>
</template>

性能优化技巧

对于长列表使用uni-virtual-list虚拟滚动:

<template>
  <uni-virtual-list 
    :list="bigData"
    :height="800"
    :itemSize="100"
  >
    <template v-slot:default="{item}">
      <view class="item">{{item.text}}</view>
    </template>
  </uni-virtual-list>
</template>

主题适配方案

通过CSS变量实现暗黑模式切换:

.list-item {
  background: var(--bg-color);
  color: var(--text-color);
}
:root {
  --bg-color: #ffffff;
  --text-color: #333333;
}
.dark {
  --bg-color: #1a1a1a;
  --text-color: #f0f0f0;
}

好看的uniapp列表

标签: 好看列表
分享给朋友:

相关文章

vue实现列表权限

vue实现列表权限

实现列表权限控制的方法 在Vue中实现列表权限控制通常涉及前端逻辑与后端数据的配合。以下是几种常见方法: 基于角色或权限码的渲染控制 通过v-if或v-show指令根据用户权限动态渲染列表项:…

vue实现奇偶列表

vue实现奇偶列表

Vue实现奇偶列表样式 在Vue中实现列表项的奇偶不同样式,可以通过多种方式实现。以下是几种常见方法: 使用v-for和动态class绑定 通过v-for循环生成列表时,利用索引值判断奇偶性并绑定…

vue列表怎么实现

vue列表怎么实现

Vue 列表实现方法 使用 v-for 指令 Vue 中列表渲染主要通过 v-for 指令实现,可以遍历数组或对象。 <template> <ul> <l…

vue实现筛选列表

vue实现筛选列表

Vue 实现筛选列表的方法 数据绑定与列表渲染 使用 v-for 指令渲染原始列表,绑定到 data 中的数组。例如: data() { return { items: […

vue实现纵向列表

vue实现纵向列表

实现纵向列表的基本方法 在Vue中实现纵向列表可以通过v-for指令结合数组数据渲染。核心是利用循环遍历数据生成列表项,并设置CSS控制纵向排列。 <template> <d…

vue实现图片列表

vue实现图片列表

实现图片列表的基本方法 在Vue中实现图片列表可以通过v-for指令遍历图片数据数组,结合<img>标签动态绑定src属性。以下是基本实现步骤: <template> &…