当前位置:首页 > 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变量实现暗黑模式切换:

好看的uniapp列表

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

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

相关文章

vue公共列表的实现

vue公共列表的实现

Vue 公共列表的实现方法 在 Vue 中实现公共列表组件,可以通过封装可复用的逻辑和模板来完成。以下是几种常见的实现方式: 使用 props 和 slots 通过 props 接收列表数据,使用…

vue实现列表页

vue实现列表页

Vue 实现列表页的方法 数据绑定与渲染 使用 v-for 指令动态渲染列表数据,结合 :key 确保渲染性能。示例代码: <template> <ul> <…

vue实现传输列表

vue实现传输列表

Vue 实现传输列表 在 Vue 中实现传输列表功能,通常涉及两个列表之间的数据传递,用户可以通过按钮或拖拽操作将项目从一个列表移动到另一个列表。以下是实现传输列表的几种方法。 使用组件间数据传递…

vue实现列表高亮

vue实现列表高亮

Vue 列表高亮实现方法 动态类绑定 通过 v-bind:class 或简写 :class 实现条件高亮 <template> <ul> <li…

vue实现无限滚动列表

vue实现无限滚动列表

实现无限滚动列表的核心思路 无限滚动列表的核心是通过监听滚动事件,动态加载数据。当用户滚动到列表底部附近时,触发数据加载,实现无缝的内容追加。 使用Intersection Observer API…

vue如何实现列表渲染

vue如何实现列表渲染

使用 v-for 指令进行列表渲染 Vue 通过 v-for 指令实现列表渲染。v-for 可以遍历数组或对象,并为每个元素生成对应的 DOM 节点。 语法示例: <ul> <…