codecamp

百度智能小程序 列表项

list-item 列表项

解释:列表项,支持三种样式可配,单行、多行列表、左右布局等,具体可看代码示例。适用于信息展示,并可放置在页面的任何位置。

属性说明

属性名 类型 必填 默认值 说明

type

String

'single'

样式类型,single 单行、list 列表、multiple 左右两列布局

title

String

''

标题文案 type === list 时必填

label

String

''

左侧标题文案

content

String

''

右侧内容文案

list

Array

[]

列表数据:数据示例[{label: '', content: ''}] 字段名可通过 listLabelName 和 listContentName 自定义

listLabelName

String

'label'

自定义 list 渲染字段名 label

listContentName

String

'content'

自定义 list 渲染字段名 content

disable

Boolean

false

是否禁用,非禁用自带点击态

smt-label

String

提供扩展样式类,供开发者自定义组件样式。可通过此 class 修改标题区左侧文案样式

smt-content

String

提供扩展样式类,供开发者自定义组件样式。可通过此 class 修改标题区右侧文案样式

smt-list-label

String

提供扩展样式类,供开发者自定义组件样式。可通过此 class 修改列表区左侧文案样式

smt-list-content

String

提供扩展样式类,供开发者自定义组件样式。可通过此 class 修改列表区右侧文案样式

示例 

在开发者工具中打开


代码示例

<view class="list-item-container">
    <block s-for="{{list}}">
        <block s-if="{{item.type === 'single'}}">
            <view class="title">{{item.title}}</view>
            <smt-list-item
                s-for="{{item.list}}"
                label="{{item.label}}"
                smt-label="smt-label"
                smt-content="smt-content"
                content="{{item.content}}"
                disable="{{item.disable}}"
            ></smt-list-item>
        </block>
        <block s-if="{{item.type === 'list'}}">
            <view class="title">{{item.title}}</view>
            <smt-list-item
                type="list"
                smt-list-label="smt-list-label"
                smt-list-content="smt-list-content"
                title="{{item.listTitle}}"
                list="{{item.list}}"
            ></smt-list-item>
        </block>
        <block s-if="{{item.type === 'multiple'}}">
            <view class="title">{{item.title}}</view>
            <smt-list-item
                type="multiple"
                list="{{item.list}}"
            ></smt-list-item>
        </block>
    </block>
</view>
Page({
    data: {
        list: [
            {
                type: 'single',
                title: '默认样式',
                list: [
                    {
                        label: '四字标题',
                        content: '展示文字内容信息'
                    },
                    {
                        label: '六字标题排版',
                        content: '展示超长文字内容信息'
                    }
                ]
            },
            {
                type: 'single',
                title: '多行内容样式',
                list: [
                    {
                        label: '超出六字标题折行',
                        content: '展示超长文字内容信息超出后折行显示,展示超长文字内容信息超出后折行显示'
                    }
                ]
            },
            {
                type: 'single',
                title: '可跳转样式',
                list: [
                    {
                        label: '四字标题',
                        content: '展示文字内容信息',
                        disable: true
                    },
                    {
                        label: '六字标题排版',
                        content: '展示超长文字内容信息',
                        disable: true
                    },
                    {
                        label: '六字标题排版',
                        content: '长短标题混排时,统一按最长标题排版',
                        disable: true
                    }
                ]
            },
            {
                type: 'single',
                title: '长短标题混排规则',
                list: [
                    {
                        label: '四字标题',
                        content: '展示长文字信息内容超出后折行显示'
                    },
                    {
                        label: '六字标题排版',
                        content: '长短标题混排时,统一按最长标题排版'
                    }
                ]
            },
            {
                type: 'list',
                title: '多行多列列表',
                listTitle: '标题信息超长文本内容展示,超出一行内容折行显示',
                list: [
                    {
                        label: '四字标题',
                        content: '展示文字内容信息'
                    },
                    {
                        label: '六字及以上标题',
                        content: '展示超长文字内容信息'
                    },
                    {
                        label: '六字标题排版',
                        content: '展示文本内容信息'
                    }
                ]
            },
            {
                type: 'multiple',
                title: '左右文字双行',
                list: [
                    {
                        label: '标题内容信息',
                        content: '辅助信息'
                    },
                    {
                        label: '标题内容信息',
                        content: '辅助信息'
                    }
                ]
            }
        ]
    }
});
.smt-label {
    <!-- 可通过此 class 修改标题区左侧文案样式。 -->
}

.smt-content {
    <!-- 可通过此 class 修改标题区右侧文案样式。 -->
}

.smt-list-label {
    <!-- 可通过此 class 修改列表区左侧文案样式。 -->
}

.smt-list-content {
    <!-- 可通过此 class 修改列表区右侧文案样式。 -->
}
{
    "navigationBarTitleText": "列表项",
    "usingComponents": {
        "smt-list-item": "@smt-ui/component/src/list-item"
    }
}


百度智能小程序 列表
百度智能小程序 折叠面板
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }