当前位置:首页 > 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阴影效果实现卡片式设计,适合商品展示等场景:

好看的uniapp列表

<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>

交互增强列表

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

好看的uniapp列表

<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;
}

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

相关文章

jquery列表

jquery列表

jQuery 列表操作 jQuery 提供了多种方法来操作 HTML 列表(如 <ul> 或 <ol>),包括动态添加、删除、修改列表项,以及事件绑定等。 创建列表 使用 j…

vue实现功能列表

vue实现功能列表

Vue 实现功能列表的方法 在 Vue 中实现功能列表通常涉及数据绑定、列表渲染、事件处理和状态管理。以下是几种常见的方法: 数据驱动列表渲染 使用 v-for 指令可以轻松实现列表渲染。假设有一个…

vue实现产品列表

vue实现产品列表

Vue 实现产品列表的方法 使用 Vue CLI 创建项目 安装 Vue CLI 并初始化项目,确保项目环境配置正确。 npm install -g @vue/cli vue create prod…

vue实现索引列表

vue实现索引列表

Vue 实现索引列表 使用第三方库(如 better-scroll 或 vue-index-list) 安装 better-scroll 或 vue-index-list 库,可以快速实现带索引的列表…

vue实现列表高亮

vue实现列表高亮

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

vue实现列表查询

vue实现列表查询

Vue 实现列表查询功能 在 Vue 中实现列表查询功能通常需要结合数据绑定、事件处理和过滤逻辑。以下是几种常见的实现方式: 使用计算属性过滤列表 计算属性是 Vue 中实现列表查询的高效方式,它会…