### Tooltip Usage Examples Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tooltip.md Examples demonstrating how to use the Tooltip component with different configurations. ```APIDOC ## Tooltip Usage Examples ### Example 1: Tooltip with Popper Class This example shows how to apply a custom CSS class to the tooltip's popper element. ```html ``` ### Example 2: Tooltip with Popper Style This example demonstrates applying inline styles to the tooltip's popper element. ```html ``` ``` -------------------------------- ### Install Layui Vue with npm Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/guide/getStarted.md Use npm to install the layui-vue package. If installation is slow, consider using pnpm or an alternative mirror source. ```bash npm install @layui/layui-vue --save ``` -------------------------------- ### Install Auto-Import Plugins Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/guide/getStarted.md Install the necessary plugins for automatic component and auto-import functionality. ```bash npm install -D @layui/unplugin-vue-components unplugin-auto-import ``` -------------------------------- ### Install Icon Package Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/icon.md Install the @layui/icons-vue package to access individual icon components. ```bash npm install @layui/icons-vue ``` -------------------------------- ### Install Layui Vue via Package Managers Source: https://context7.com/lunar-landing/layui-vue/llms.txt Use npm, yarn, or pnpm to install the main package into your project. ```bash # 安装主包 npm install @layui/layui-vue # 或使用 yarn yarn add @layui/layui-vue # 或使用 pnpm pnpm add @layui/layui-vue ``` -------------------------------- ### Basic Tab Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tab.md A simple example demonstrating the basic usage of the Layui-Vue Tab component. ```APIDOC ## POST /api/users ### Description Creates a new user in the system. ### Method POST ### Endpoint `/api/users` ### Parameters #### Request Body - **username** (string) - Required - The username for the new user. - **email** (string) - Required - The email address for the new user. - **password** (string) - Required - The password for the new user. ### Request Example ```json { "username": "johndoe", "email": "john.doe@example.com", "password": "securepassword123" } ``` ### Response #### Success Response (201) - **id** (string) - The unique identifier for the newly created user. - **username** (string) - The username of the created user. - **email** (string) - The email address of the created user. #### Response Example ```json { "id": "user-12345", "username": "johndoe", "email": "john.doe@example.com" } ``` ``` -------------------------------- ### Basic Menu Structure Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/menu.md Demonstrates a basic Layui-Vue menu with selected key and open keys configuration. Ensure 'vue' is installed. ```vue ``` -------------------------------- ### Install Independent Layer Package Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/layer.md Instructions for installing and configuring the standalone layer package for use with other component libraries. ```bash npm install @layui/layer-vue ``` ```js import { createApp } from "vue"; import layer from "@layui/layer-vue"; import "@layui/layer-vue/lib/index.css"; import App from "./App.vue"; const app = createApp(App); app.use(layer); app.mount("#app"); ``` -------------------------------- ### Layui-Vue Tree Component Examples Source: https://context7.com/lunar-landing/layui-vue/llms.txt Illustrates the lay-tree component for displaying hierarchical data. Includes basic tree structure, trees with checkboxes, and trees with lazy loading capabilities. Requires 'vue' setup. ```vue ``` -------------------------------- ### beforeUpload Hook Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/upload.md Example of using the `beforeUpload` hook to validate files before uploading. ```APIDOC ## POST /api/upload (Example) ### Description This example demonstrates how to use the `beforeUpload` hook to prevent files larger than 1000 KB from being uploaded. ### Method POST ### Endpoint `/api/upload` ### Parameters #### Query Parameters None #### Request Body None (handled by the component) ### Request Example ```json { "file": "" } ``` ### Response #### Success Response (200) - **data** (object) - Upload result details #### Response Example ```json { "data": "{\"url\": \"http://example.com/file.jpg\"}" } ``` ### Error Handling - **400 Bad Request**: Invalid file format or size. - **500 Internal Server Error**: Server-side upload failure. ``` -------------------------------- ### TagInput Setup Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tagInput.md Basic setup for the TagInput component using Vue's Composition API. Initializes reactive data for tags and input values. ```javascript export default { setup() { const data7 = ref(['标签1','标签2']); const inputValue7 = ref(""); return { data7, inputValue7 } } } ``` -------------------------------- ### Online Installation with CDN Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/guide/getStarted.md Include Layui Vue using a CDN provider, demonstrated here with unpkg. This method allows for quick integration without a build process. ```html
{{ message }}
``` -------------------------------- ### Tab Position and Type Configuration Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tab.md Example showing how to change the tab position and type. ```APIDOC ## DELETE /api/products/{productId} ### Description Deletes a specific product from the system. ### Method DELETE ### Endpoint `/api/products/{productId}` ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product to delete. ### Response #### Success Response (204) No content is returned on successful deletion. #### Response Example (No content) ``` -------------------------------- ### Basic Usage of Layui-Vue Loading Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/loading.md Demonstrates how to use the `lay-loading` component with different types. No specific setup is required beyond importing the component. ```vue ``` -------------------------------- ### Nested Drawer Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/drawer.md Demonstrates how to open a new drawer from within an existing one to handle multi-step processes. Ensure proper `v-model` binding for each drawer. ```html ``` ```javascript import { ref } from 'vue' export default { setup() { const visible1 = ref(false) const changeVisible1 = function() { visible1.value = !visible1.value; } const visible2 = ref(false) const changeVisible2 = function() { visible2.value = !visible2.value; } return { visible1, visible2, changeVisible1, changeVisible2 } } } ``` -------------------------------- ### Basic Notice Bar Usage Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/noticeBar.md Displays a simple notice bar with text. No specific setup is required beyond including the component. ```html ``` ```javascript export default { setup() { return { } } } ``` -------------------------------- ### Form Submission and Validation Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/form.md Demonstrates how to submit a form and handle validation results using Layui Vue's form component. ```APIDOC ## POST /api/submit-form ### Description This endpoint handles the submission of form data and provides validation results. ### Method POST ### Endpoint /api/submit-form ### Parameters #### Request Body - **model** (object) - Required - The form data model. - **errors** (object) - Required - Validation errors, if any. ### Request Example ```json { "model": { "specialty": { "x": [ { "y": "1" } ] }, "aaaaaaaaa": "aaaaa" }, "errors": {} } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message. #### Response Example ```json { "message": "Form submitted successfully" } ``` ``` -------------------------------- ### Upload Component Basic Usage Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/upload.md Demonstrates the basic setup for the layui-vue Upload component, including how to define a preview slot and handle upload completion. ```javascript const getFileDone=(res)=>{ console.log("getFileDone",res); }; ``` -------------------------------- ### Layui-Vue Menu Component Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/menu.md Demonstrates a configurable menu component with nested items, theme switching, and collapse functionality. Ensure the necessary Vue and Layui-Vue imports are present. ```html ``` ```javascript import { ref } from 'vue' export default { setup() { const selectedKey20 = ref("5") const openKeys20 = ref(["7"]) const collapse20 = ref(true) const isTree20 = ref(true) const active20 = ref(true) return { selectedKey, openKeys6, colapse, isTree, active20 } } } ``` -------------------------------- ### Basic Badge Examples Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/badge.md Demonstrates different ways to use the lay-badge component with various attributes like type, theme, color, and ripple effect. ```html ``` ```html ``` ```html ``` -------------------------------- ### Tab Component Setup Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tab.md Sets up the reactive state for the tab component, including the currently active tab, the array of tab items, and functions to handle tab changes and additions. ```javascript import { ref } from 'vue' export default { setup() { const current6 = ref('1') const change6 = function(id){ alert(id) } const arr = ref([ {id:'1', title:'选项一', closable: false}, {id:'2', title:'选项二'}, {id:'3', title:'选项三'} ]) return { current6, arr } } } ``` ```javascript import { ref } from 'vue' export default { setup() { let index = 4; const current8 = ref('1') const arr2 = ref([ {id:'1', title:'选项一', closable: false}, {id:'2', title:'选项二'}, {id:'3', title:'选项三'} ]) const addTab = function(){ index++; arr2.value.push({ id: String(index), title:'新选项卡' + index }) current8.value = String(index); } return { arr2, addTab, current8 } } } ``` ```javascript import { ref } from 'vue' export default { setup() { const current7 = ref("1"); const tabPosition = ref("left"); const tabType = ref("brief"); return { current2, tabPosition, tabType } } } ``` -------------------------------- ### Basic Container Usage Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/container.md Use the basic lay-container component to wrap your content. This example demonstrates a standard container with a fixed width and height for visual demonstration. ```vue ``` -------------------------------- ### LayTimeSelect Usage Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/timeSelect.md Example of how to use the LayTimeSelect component in a Vue.js application. ```javascript import { ref } from 'vue'; const time1 = ref('08:00:00'); const time2 = ref(); const time3 = ref(); const time4 = ref(); const time5 = ref(); const time6 = ref(); ``` -------------------------------- ### Basic Usage Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/switch.md Demonstrates the fundamental implementation of the switch component. ```APIDOC ## Basic Usage ### Description This section shows how to use the `lay-switch` tag to create a basic switch. ### Method N/A (Component Usage) ### Endpoint N/A (Component Usage) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```html ``` ### Response N/A (Component Usage) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Cascader Data Structure Example Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/cascader.md Example of the hierarchical data structure used for the options property in the Cascader component. ```javascript {label: "横县", value: '450127'}, ]}, {label: "柳州", value: '450200', children: [ {label: "市辖区", value: '450201'}, {label: "城中区", value: '450202'}, {label: "鱼峰区", value: '450203'}, {label: "柳南区", value: '450204'}, {label: "柳北区", value: '450205'}, {label: "柳江县", value: '450221'}, {label: "鹿寨县", value: '450222'}, {label: "融安县", value: '450223'}, {label: "融水苗族自治县", value: '450224'}, {label: "三江侗族自治县", value: '450225'}, ]}, {label: "桂林", value: '450300', children: [ {label: "市辖区", value: '450301'}, {label: "秀峰区", value: '450302'}, {label: "叠彩区", value: '450303'}, {label: "象山区", value: '450304'}, {label: "七星区", value: '450305'}, {label: "雁山区", value: '450311'}, {label: "临桂区", value: '450312'}, {label: "阳朔县", value: '450321'}, {label: "灵川县", value: '450322'}, {label: "全州县", value: '450323'}, {label: "兴安县", value: '450324'}, {label: "永福县", value: '450325'}, {label: "灌阳县", value: '450326'}, {label: "龙胜各族自治县", value: '450327'}, {label: "资源县", value: '450328'}, {label: "平乐县", value: '450329'}, {label: "荔浦县", value: '450330'}, {label: "恭城瑶族自治县", value: '450331'}, ]}, ]} ``` -------------------------------- ### 克隆仓库 Source: https://github.com/lunar-landing/layui-vue/blob/master/CONTRIBUTING.md 将 fork 后的仓库克隆到本地并进入项目目录。 ```bash git clone https://gitee.com/your-username/layui-vue.git cd layui-vue ``` -------------------------------- ### Initialize LayTimeSelect with Vue Composition API Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/timeSelect.md Basic setup for using LayTimeSelect with reactive variables in a Vue 3 script setup block. ```vue ``` -------------------------------- ### Open Layer with Multiple Callbacks Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/layer.md Illustrates opening a layer and configuring numerous callbacks for various events, including success, end, close, beforeClose, moveStart, moving, moveEnd, resizeStart, resizing, and resizeEnd. This provides comprehensive control over the layer's lifecycle. ```javascript const openCallback = () => { layer.open({ title:"标题", content:"内容", maxmin: true, shade: false, min: (id) => { console.log(`最小化:${id}`) }, full: (id) => { console.log(`最大化:${id}`) }, revert: (id) => { console.log(`最小/最大化还原:${id}`) }, success: (id) => { console.log(`成功:${id}`) }, end: (id) => { console.log(`销毁:${id}`) }, close: (id) => { console.log(`关闭:${id}`) }, beforeClose: (id) => { console.log(`关闭前置:${id}`) }, moveStart: (id) => { console.log(`拖拽开始:${id}`) }, moving: (id, {top, left}) => { console.log(`拖拽中:${id}`) }, moveEnd: (id) => { console.log(`拖拽结束:${id}`) }, resizeStart: (id) => { console.log(`拉伸开始:${id}`) }, resizing: (id, {width, height}) => { console.log(`拉伸中:${id}`) }, resizeEnd: (id) => { console.log(`拉伸结束:${id}`) } }) } ``` -------------------------------- ### Tab with Nested Loops Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/tab.md Example of using v-for to create tabs dynamically. ```APIDOC ## GET /api/products/{productId} ### Description Retrieves details for a specific product. ### Method GET ### Endpoint `/api/products/{productId}` ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the product. - **name** (string) - The name of the product. - **description** (string) - A description of the product. - **price** (number) - The price of the product. #### Response Example ```json { "id": "prod-abcde", "name": "Example Widget", "description": "A high-quality widget for various uses.", "price": 19.99 } ``` ``` -------------------------------- ### Layui Vue Select Component Examples Source: https://context7.com/lunar-landing/layui-vue/llms.txt Demonstrates various configurations of the lay-select component, including single selection, multiple selection, searchable input, rendering from options array, grouped options, and disabled state. ```vue ``` -------------------------------- ### Updated Icons Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/icon.md Example of icons added in version 1.11.0 of layui-vue or 1.1.0 of icons-vue. ```vue ``` -------------------------------- ### Basic Step Usage Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/step.md Demonstrates the fundamental implementation of the step component with navigation buttons. ```vue ``` -------------------------------- ### Badge Positioning Examples Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/badge.md Illustrates different positioning options for badges, such as bottom-right, bottom-left, and top-left, when attached to an avatar. ```vue ``` -------------------------------- ### Comprehensive Layer Demonstration Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/layer.md Demonstrates various layer types including Message, Confirm, Loading, Iframe, Drawer, Notify, Photos, and Prompt. ```vue ``` -------------------------------- ### Breadcrumb with Custom Separator Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/breadcrumb.md Customize the separator between breadcrumb items using the `separator` attribute. This example uses a '>' character. ```vue ``` -------------------------------- ### Grid Responsiveness Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/grid.md Explains how to make grid layouts responsive using different column sizes for various screen sizes. ```APIDOC ## Grid Responsiveness ### Description This section details how to create responsive grid layouts by applying different column sizes (`xs`, `sm`, `md`, `lg`) to `lay-col` components, allowing the layout to adapt to different screen sizes. ### Method Component Usage ### Endpoint N/A ### Parameters #### Col Attributes (Responsive Sizes) - **xs** (number | string) - Optional - Column size for extra-small screens (< 768px), range 0-24. - **sm** (number | string) - Optional - Column size for small screens (≥ 768px), range 0-24. - **md** (number | string) - Optional - Column size for medium screens (≥ 992px), range 0-24. - **lg** (number | string) - Optional - Column size for large screens (≥ 1200px), range 0-24. ### Request Example ```html ``` ### Response N/A (Component rendering) ``` -------------------------------- ### Create Message Windows Source: https://github.com/lunar-landing/layui-vue/blob/master/docs/src/document/zh-CN/components/layer.md Demonstrates creating various message windows using layer.msg with different icons and configurations. ```vue ```