{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `ui.list`\n", "\n", "## 列表\n", "\n", "基于 Quasar 的 [QList](https://quasar.dev/vue-components/list-and-list-items#qlist-api) 组件的列表元素。它为列表项提供了一个容器。" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from nicegui import ui\n", "\n", "with ui.list().props('dense separator'):\n", " with ui.item():\n", " with ui.item_section():\n", " ui.item_label('3 Apples')\n", " with ui.item():\n", " with ui.item_section():\n", " ui.item_label('5 Bananas')\n", " with ui.item():\n", " with ui.item_section():\n", " ui.item_label('8 Strawberries')\n", " with ui.item():\n", " with ui.item_section():\n", " ui.item_label('13 Walnuts')\n", "\n", "# ui.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 列表项、分区和标签\n", "\n", "列表项使用项目分区来组织其内容。根据属性的不同,项目标签的位置也不同。" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from nicegui import ui\n", "\n", "with ui.list().props('bordered separator'):\n", " ui.item_label('Contacts').props('header').classes('text-bold')\n", " ui.separator()\n", " with ui.item(on_click=lambda: ui.notify('Selected contact 1')):\n", " with ui.item_section().props('avatar'):\n", " ui.icon('person')\n", " with ui.item_section():\n", " ui.item_label('Nice Guy')\n", " ui.item_label('name').props('caption')\n", " with ui.item_section().props('side'):\n", " ui.icon('chat')\n", " with ui.item(on_click=lambda: ui.notify('Selected contact 2')):\n", " with ui.item_section().props('avatar'):\n", " ui.icon('person')\n", " with ui.item_section():\n", " ui.item_label('Nice Person')\n", " ui.item_label('name').props('caption')\n", " with ui.item_section().props('side'):\n", " ui.icon('chat')\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }