### Input Component Examples in Vue Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates the various configurations of the L-Input component in Vue.js, including different input types, status indicators, icons, clear buttons, and layout options. It utilizes Vue's reactivity system with `ref` and `computed` for dynamic behavior. ```html ``` -------------------------------- ### HTTP Client: Making Requests with lime-request Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates how to create an HTTP client instance, configure interceptors for requests and responses, and perform various HTTP operations like GET, POST, PUT, DELETE, file upload, and download. It also shows how to handle request cancellation. ```javascript import { Request } from '@/uni_modules/lime-request' // Create request instance const api = new Request({ baseURL: 'https://api.example.com', timeout: 15000, header: { 'Content-Type': 'application/json' } }) // Request interceptor - add auth token api.interceptors.request.use( (config) => { const token = uni.getStorageSync('token') if (token) { config.header.Authorization = `Bearer ${token}` } return config }, (error) => Promise.reject(error) ) // Response interceptor - handle errors api.interceptors.response.use( (response) => { if (response.data.code !== 200) { uni.showToast({ title: response.data.message, icon: 'none' }) return Promise.reject(response.data) } return response.data }, (error) => { uni.showToast({ title: 'Network error', icon: 'error' }) return Promise.reject(error) } ) // GET request with params api.get('/users', { params: { page: 1, limit: 10 } }) .then(res => console.log('Users:', res.data)) // POST request with body api.post('/users', { name: 'John', email: 'john@example.com' }) .then(res => console.log('Created:', res.data)) // PUT request api.put('/users/123', { name: 'John Updated' }) // DELETE request api.delete('/users/123') // File upload api.upload('/upload', { filePath: '/path/to/image.jpg', name: 'file', formData: { type: 'avatar' } }).then(res => console.log('Uploaded:', res.data)) // File download api.download('/files/document.pdf', { filePath: `${uni.env.USER_DATA_PATH}/document.pdf` }).then(res => console.log('Downloaded to:', res.tempFilePath)) // Request with task for cancellation let task = null api.get('/long-running', { getTask: (t) => { task = t } }) // Cancel request: task.abort() ``` -------------------------------- ### Dialog - Confirmation Modal Examples (Vue) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Illustrates the L-Dialog component for displaying confirmation messages and prompts. It supports both declarative (v-model) and imperative (ref.show()) usage patterns, along with custom content via slots. Event handlers for confirm and cancel actions are included. ```html ``` -------------------------------- ### Popup - Modal Layer Examples (Vue) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates the usage of the L-Popup component for creating modal layers with different positions (bottom, center, right drawer). It supports customizable animations, overlay controls, and safe area insets. The component is controlled using Vue's ref for visibility. ```html ``` -------------------------------- ### ConfigProvider - Global Theme Configuration for LimeUI+ Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt The ConfigProvider component manages global theme settings for LimeUI+ components. It allows for light/dark mode switching and custom theme variables via CSS custom properties. This example demonstrates how to toggle themes and apply custom styles. ```html ``` -------------------------------- ### Button - Action Trigger Component for LimeUI+ Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt The Button component in LimeUI+ is a versatile element for triggering actions. It supports various types, variants, sizes, shapes, and states like loading. This example showcases basic usage, different styles, and icon integration. ```html ``` -------------------------------- ### Date Utilities: Manipulating Dates with lime-dayuts Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Illustrates the usage of the lime-dayuts library for various date operations. It covers parsing dates from different formats, formatting dates into custom strings, getting and setting date components, performing date arithmetic, comparing dates, calculating differences, and working with relative time expressions. ```javascript import { dayuts } from '@/uni_modules/lime-dayuts' // Current date/time dayuts().format() // "2024-06-15T10:30:00+08:00" dayuts().format('YYYY-MM-DD') // "2024-06-15" dayuts().format('YYYY年MM月DD日 HH:mm') // "2024年06月15日 10:30" // Parse various formats dayuts('2024-06-15') dayuts('2024-06-15T10:30:00.000Z') dayuts(1718438400000) // timestamp dayuts(new Date()) // Get/Set values dayuts().year() // 2024 dayuts().month() // 5 (0-indexed) dayuts().date() // 15 dayuts().day() // 6 (Saturday) dayuts().hour() // 10 dayuts().minute() // 30 // Manipulate dates dayuts().add(7, 'day').format('YYYY-MM-DD') // Add 7 days dayuts().subtract(1, 'month') // Subtract 1 month dayuts().startOf('month') // First day of month dayuts().endOf('year') // Last moment of year // Compare dates const date1 = dayuts('2024-06-15') const date2 = dayuts('2024-06-20') date1.isBefore(date2) // true date1.isAfter(date2) // false date1.isSame(date2, 'month') // true dayuts('2024-06-15').isBetween('2024-06-01', '2024-06-30') // true // Difference date2.diff(date1, 'day') // 5 date2.diff(date1, 'hour') // 120 // Relative time dayuts().fromNow() // "just now" dayuts().subtract(3, 'hour').fromNow() // "3 hours ago" dayuts().add(2, 'day').fromNow() // "in 2 days" // Utility methods dayuts('2024-02-15').daysInMonth() // 29 (leap year) dayuts('2024-02-15').isLeapYear() // true dayuts().isToday() // true dayuts().toDate() // native Date object dayuts().unix() // Unix timestamp in seconds ``` -------------------------------- ### Navbar - Navigation Header with Slots and Customization (Vue.js) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Illustrates the Navbar component for creating navigation headers. It supports customizable titles, back buttons, status bar adaptation, and flexible content insertion via slots for elements like search bars, icons, and dropdown menus. Includes examples of fixed positioning and custom background styling. ```html ``` ```javascript import { ref } from 'vue' const searchValue = ref('') const showDropdown = ref(false) const onBack = () => { const pages = getCurrentPages() if (pages.length > 1) { uni.navigateBack() } else { uni.switchTab({ url: '/pages/index/index' }) } } const onScan = () => { uni.scanCode({ success: (res) => console.log('Scanned:', res.result) }) } ``` -------------------------------- ### EChart Data Visualization Component (Vue/HTML) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Integrates ECharts for rendering interactive charts with full configuration support. This component requires a Vue template and JavaScript setup, including the ECharts library. It supports initialization, data updates, resizing, and exporting charts as images. ```html ``` ```javascript import { ref } from 'vue' // #ifdef MP const echarts = require('../../static/echarts.min.js') // #endif // #ifndef MP const echarts = null // #endif const chartRef = ref(null) const initChart = async () => { if (!chartRef.value) return const chart = await chartRef.value.init(echarts) chart.setOption({ title: { text: 'Sales Overview', left: 'center' }, tooltip: { trigger: 'axis' }, legend: { data: ['Sales', 'Revenue'], bottom: 0 }, xAxis: { type: 'category', data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'] }, yAxis: { type: 'value' }, series: [ { name: 'Sales', type: 'bar', data: [120, 200, 150, 80, 70, 110], itemStyle: { color: '#1677ff' } }, { name: 'Revenue', type: 'line', data: [150, 230, 180, 100, 90, 130], itemStyle: { color: '#52c41a' } } ] }) } // Update chart data const updateChart = (newData) => { chartRef.value?.setOption({ series: [{ data: newData }] }) } // Resize chart const resizeChart = () => { chartRef.value?.resize() } // Export as image const exportChart = () => { chartRef.value?.canvasToTempFilePath({ success: (res) => { uni.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: () => uni.showToast({ title: 'Saved!' }) }) } }) } ``` -------------------------------- ### Form Validation Component in Vue Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Illustrates the L-Form component in Vue.js for handling form data and validation. It showcases how to define reactive form data, validation rules (required, length, pattern, custom validators), and integrate with form items and buttons for submission and reset. The example uses `ref` and `reactive` for state management. ```html ``` -------------------------------- ### ActionSheet - Bottom Actions with Icons and Grid Layout (Vue.js) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates the usage of the ActionSheet component for presenting lists of actions at the bottom of the screen. Supports icons, descriptions, custom styling, and a grid layout for sharing options. It utilizes Vue.js reactivity and event handling for user interactions. ```html ``` ```javascript import { ref } from 'vue' const showBasic = ref(false) const showDesc = ref(false) const showGrid = ref(false) const basicActions = [ { label: 'Edit' }, { label: 'Share' }, { label: 'Delete', color: '#ff3b30' } ] const descActions = [ { label: 'Copy Link', icon: 'link' }, { label: 'Save to Album', icon: 'download' }, { label: 'Report', icon: 'warning', disabled: true } ] const shareOptions = [ { label: 'WeChat', icon: 'https://example.com/wechat.png', bgColor: '#07c160' }, { label: 'Moments', icon: 'https://example.com/moments.png', bgColor: '#07c160' }, { label: 'QQ', icon: 'https://example.com/qq.png', bgColor: '#12b7f5' }, { label: 'Weibo', icon: 'https://example.com/weibo.png', bgColor: '#e6162d' }, { label: 'Copy Link', icon: 'link' }, { label: 'QR Code', icon: 'qrcode' }, { label: 'More', icon: 'more' } ] const onSelect = (index, item) => { console.log('Selected:', item.label) showBasic.value = false } const onShare = (index, item) => { console.log('Share to:', item.label) showGrid.value = false // Implement share logic } ``` -------------------------------- ### Toast - Lightweight Notifications API (Vue) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates the L-Toast component for displaying non-blocking notifications. It utilizes API functions for different types (success, error, loading) and custom configurations. A toast agent must be placed on the page, and toasts can be hidden programmatically. ```html ``` -------------------------------- ### File Upload Component with Vue.js Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Demonstrates the 'l-upload' component for handling file uploads. Supports image and video uploads, multiple selections, preview, progress tracking, auto-upload to custom servers or uniCloud, and custom upload triggers. It uses Vue.js for its reactive nature and component-based structure. ```html ``` -------------------------------- ### SQLite Local Database Operations (JavaScript) Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Provides native SQLite database API for persistent local storage on Android, iOS, and HarmonyOS. Supports CRUD operations, transactions, and SQL queries. Requires the '@/uni_modules/lime-sqlite' module. ```javascript import { openDatabase, closeDatabase, isOpenDatabase, executeSql, selectSql, transaction, getDatabasePath } from '@/uni_modules/lime-sqlite' // Open database openDatabase({ name: 'myapp', success: (res) => console.log('Database opened'), fail: (err) => console.error('Failed to open:', err) }) // Check if database is open isOpenDatabase({ name: 'myapp', success: (res) => console.log('Is open:', res) }) // Create table executeSql({ name: 'myapp', sql: ["\n CREATE TABLE IF NOT EXISTS users (\n id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n )\n "], success: () => console.log('Table created'), fail: (err) => console.error('Create failed:', err) }) // Insert dataexecuteSql({ name: 'myapp', sql: [ "INSERT INTO users (name, email) VALUES ('John', 'john@example.com')", "INSERT INTO users (name, email) VALUES ('Jane', 'jane@example.com')" ], success: () => console.log('Users inserted') }) // Query dataselectSql({ name: 'myapp', sql: ["SELECT * FROM users WHERE name LIKE '%John%'"], success: (res) => { console.log('Query results:', res) // res = [{ id: 1, name: 'John', email: 'john@example.com', created_at: '...' }] } }) // Transaction transaction({ name: 'myapp', operation: 'begin', success: () => { executeSql({ name: 'myapp', sql: [ "UPDATE users SET name = 'John Doe' WHERE id = 1", "DELETE FROM users WHERE id = 2" ], success: () => { transaction({ name: 'myapp', operation: 'commit', success: () => console.log('Committed') }) }, fail: () => { transaction({ name: 'myapp', operation: 'rollback', success: () => console.log('Rolled back') }) } }) } }) // Get database path const dbPath = getDatabasePath('myapp') console.log('Database location:', dbPath) // Close database closeDatabase({ name: 'myapp', success: () => console.log('Database closed') }) ``` -------------------------------- ### Picker Component with Vue.js Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Showcases the 'l-picker' and 'l-cascade' components for selection functionalities. Supports single-column, multi-column, and cascade selections with customizable buttons, titles, and data structures. It integrates with 'l-popup' for modal display and uses Vue.js for state management. ```html ``` -------------------------------- ### Calendar: Date Selection with Vue.js Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Implements a calendar component for single, multiple, or range date selection. Supports custom date formatting, minimum/maximum dates, and event handling for confirmations. Requires Vue.js and Lime UI. ```html ``` ```javascript import { ref } from 'vue' const showCalendar = ref(false) const showRange = ref(false) const showCustom = ref(false) const selectedDates = ref([]) const minDate = Date.now() const maxDate = Date.now() + 90 * 24 * 60 * 60 * 1000 const formatDay = (day) => { const date = new Date(day.date) if (date.getDay() === 0 || date.getDay() === 6) { day.className = 'weekend' } return day } const customFormat = (day) => { // Add price suffix for booking scenarios const prices = { 1: '$99', 2: '$89', 3: '$79' } const weekday = new Date(day.date).getDay() if (prices[weekday]) { day.suffix = prices[weekday] } return day } const onDateConfirm = (value) => { console.log('Selected date:', new Date(value)) showCalendar.value = false } const onRangeConfirm = (values) => { const [start, end] = values.map(v => new Date(v)) console.log('Date range:', start, 'to', end) showRange.value = false } ``` -------------------------------- ### Tabs Component - Content Switching with Animations and Gestures Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt The Tabs component allows for dynamic content switching with support for animated transitions and swipe gestures. It can be used with a list of tab objects or with nested tab panel children. Customization options include colors, line styles, and badge displays. ```html ``` ```javascript import { ref } from 'vue' const activeTab = ref(0) const panelTab = ref(0) const styledTab = ref(0) const tabList = [ { label: 'Tab 1', value: 0 }, { label: 'Tab 2', value: 1 }, { label: 'Tab 3', value: 2 } ] const styledList = [ { label: 'Featured', value: 0 }, { label: 'Popular', value: 1 }, { label: 'Latest', value: 2 }, { label: 'Trending', value: 3 } ] const onTabChange = (index) => console.log('Tab changed to:', index) ``` -------------------------------- ### SwipeCell: Interactive List Actions with Vue.js Source: https://context7.com/wanpixiaohuolong/limeul/llms.txt Provides a swipeable cell component for list items, enabling actions like favorite, edit, and delete. Includes a `before-close` hook for confirmation dialogs. Requires Vue.js and Lime UI. ```html ``` ```javascript import { ref } from 'vue' const items = ref([ { id: '1', title: 'Item 1', subtitle: 'Description 1' }, { id: '2', title: 'Item 2', subtitle: 'Description 2' }, { id: '3', title: 'Item 3', subtitle: 'Description 3' } ]) const beforeClose = async (direction) => { if (direction === 'right') { // Confirm before closing on delete side return new Promise((resolve) => { uni.showModal({ title: 'Confirm', content: 'Close swipe cell?', success: (res) => resolve(res.confirm) }) }) } return true } const onSwipeOpen = (direction) => console.log('Swiped:', direction) const onFavorite = (index) => { console.log('Favorite item:', items.value[index]) } const onEdit = (index) => { uni.navigateTo({ url: `/pages/edit/index?id=${items.value[index].id}` }) } const onDelete = (index) => { uni.showModal({ title: 'Delete', content: 'Are you sure?', success: (res) => { if (res.confirm) { items.value.splice(index, 1) } } }) } ``` ```css .action-btn { display: flex; align-items: center; justify-content: center; width: 80px; height: 100%; color: #fff; } .favorite-btn { background-color: #ff9500; } .edit-btn { background-color: #1677ff; } .delete-btn { background-color: #ff3b30; } ```