### Basic Guide Component Usage (Vue Script Setup)
Source: https://uview-plus.jiangruyi.com/components/guide.html
Vue 3 script setup for the Guide component, defining reactive state for visibility and the list of onboarding steps.
```javascript
import { ref } from 'vue'
const show = ref(true)
const list = ref([
{
image: '/static/uview/common/logo.png',
title: '欢迎使用 uview-plus',
desc: '一套跨端可复用的高质量组件库。'
},
{
image: '/static/uview/common/gray-logo.png',
title: '引导页支持多页滑动',
desc: '可配置跳过、下一步和立即体验。'
},
{
image: '/static/uview/common/logo.jpg',
title: '只显示一次',
desc: '默认内置本地存储记忆能力。'
}
])
```
--------------------------------
### Guide Component: Event Handling
Source: https://uview-plus.jiangruyi.com/components/guide.html
Example of how to listen for various events emitted by the Guide component, such as page changes, skip, finish, and close.
```html
```
--------------------------------
### ShortVideo Script Setup Example
Source: https://uview-plus.jiangruyi.com/components/shortVideo.html
This script uses Vue's Composition API with `
```
--------------------------------
### Basic Signature Example
Source: https://uview-plus.jiangruyi.com/components/signature.html
Demonstrates the basic setup of the up-signature component with default settings. It includes a preview of the captured signature and a button to clear it.
```vue
基础签名示例
签名预览:
清除签名
自定义颜色和工具栏示例
签名预览:
清除签名
```
--------------------------------
### Using uParse Component with Setup Script (Aliased)
Source: https://uview-plus.jiangruyi.com/components/quickstart.html
Shows how to use the uParse component after aliasing it to avoid naming conflicts with uView Plus components. This example uses a setup script.
```vue
```
--------------------------------
### Basic Table Setup
Source: https://uview-plus.jiangruyi.com/components/table2.html
Demonstrates the basic setup for a table with columns and data using Vue's Composition API.
```vue
```
--------------------------------
### Basic Input Usage (Vue Script Setup)
Source: https://uview-plus.jiangruyi.com/components/input.html
Demonstrates the basic setup of the up-input component using Vue's script setup. It shows how to bind the input value and handle the change event.
```vue
```
--------------------------------
### Dropdown Script Setup Example
Source: https://uview-plus.jiangruyi.com/components/dropdown.html
This script uses Vue 3's Composition API to manage dropdown state, options, and event handlers for opening, closing, and changing items.
```javascript
```
--------------------------------
### Basic Guide Component Usage (Template)
Source: https://uview-plus.jiangruyi.com/components/guide.html
Template structure for the Guide component. Use `v-model:show` to control visibility and `list` to provide the onboarding data.
```html
```
--------------------------------
### Manual Increment/Decrement (Setup Script)
Source: https://uview-plus.jiangruyi.com/components/lineProgress.html
Control the progress bar's percentage value dynamically by updating the `percentage` ref. This example uses the Composition API with `
```
--------------------------------
### Install uView-plus and Dependencies
Source: https://uview-plus.jiangruyi.com/components/npmSetting.html
Install uView-plus along with Day.js and Clipboard.js. If your HBuilder X project lacks a package.json, initialize it first.
```bash
# If your project is HX created, and the root directory does not have package.json, please execute the following command first:
# npm init -y
# Install
npm install uview-plus
npm install dayjs
npm install clipboard
```
--------------------------------
### GET Request with Parameters and Local Configuration
Source: https://uview-plus.jiangruyi.com/js/http.html
Demonstrates making a GET request, including how to pass parameters and override global configurations locally. Local configurations take precedence.
```javascript
import { http, toast} from '@/uni_modules/uview-plus'
// 基本用法,注意:get请求的参数以及配置项都在第二个参数中
http.get('/user/login', {params: {userName: 'name', password: '123456'}}).then(res => {
}).catch(err => {
})
// 局部修改配置,局部配置优先级高于全局配置
http.get('/user/login', {
params: {userName: 'name', password: '123456'}, /* 会加在url上 */
header: {}, /* 会与全局header合并,如有同名属性,局部覆盖全局 */
dataType: 'json',
// 注:如果局部custom与全局custom有同名属性,则后面的属性会覆盖前面的属性,相当于Object.assign(全局,局部)
custom: {auth: true}, // 可以加一些自定义参数,在拦截器等地方使用。比如这里我加了一个auth,可在拦截器里拿到,如果true就传token
// #ifndef MP-ALIPAY
responseType: 'text',
// #endif
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
timeout: 60000, // H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)、微信小程序(2.10.0)、支付宝小程序
// #endif
// #ifdef APP-PLUS
sslVerify: true, // 验证 ssl 证书 仅5+App安卓端支持(HBuilderX 2.3.3+)
// #endif
// #ifdef APP-PLUS
firstIpv4: false, // DNS解析时优先使用ipv4 仅 App-Android 支持 (HBuilderX 2.8.0+)
// #endif
// #ifdef H5
withCredentials: false, // 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+)
// #endif
// 返回当前请求的task, options。请勿在此处修改options。非必填
getTask: (task, options) => {
// 相当于设置超时时间500ms
// setTimeout(() => {
// task.abort()
// }, 500)
},
//validateStatus: (statusCode) => { // statusCode 必存在。此处示例为全局默认配置。演示,非必填选项
// return statusCode >= 200 && statusCode < 300
//}
}).then(res => {
}).catch(err => {
})
```
--------------------------------
### SwipeAction Basic Usage Script Setup
Source: https://uview-plus.jiangruyi.com/components/swipeAction.html
This script uses `setup` syntax with `reactive` to define the `show` state and `options1` for the SwipeAction item. Ensure `ref` is imported if used.
```javascript
import { reactive } from 'vue';
const show = ref(false)
// 使用 reactive 创建响应式对象
const options1 = reactive([{
text: '删除'
}]);
```
--------------------------------
### Input with Prefix and Suffix Slots (Vue 3 Setup Script)
Source: https://uview-plus.jiangruyi.com/components/input.html
Demonstrates how to use prefix and suffix slots in the u-input component with Vue 3's setup script. This example shows adding 'http://' as a prefix and a verification code button with a countdown as a suffix. Note the conditional rendering for APP-NVUE compatibility.
```vue
前后插槽
```
--------------------------------
### Responsive Column Count for Grid Layout (Composition API)
Source: https://uview-plus.jiangruyi.com/components/dragsort.html
This example demonstrates responsive column behavior for the grid layout using the Composition API with Vue's `
```
--------------------------------
### Install Additional Dependencies
Source: https://uview-plus.jiangruyi.com/components/downloadSetting.html
Install the 'dayjs' and 'clipboard' npm packages, which may be required by certain uView-plus components or functionalities.
```bash
npm i dayjs
npm i clipboard
```
--------------------------------
### Basic Usage with Vue 3 Setup Script
Source: https://uview-plus.jiangruyi.com/components/code.html
Demonstrates the basic usage of the up-code component with Vue 3's setup script. It shows how to handle countdowns, display prompts, and prevent multiple requests during the countdown.
```vue
{{tips}}
```
--------------------------------
### GET Request
Source: https://uview-plus.jiangruyi.com/js/http.html
Illustrates how to perform a GET request, emphasizing that all parameters and configuration options are passed as the second argument. It also shows how to override global configurations with local ones.
```APIDOC
## GET Request
```javascript
import { http, toast} from '@/uni_modules/uview-plus'
// Basic usage: parameters and configuration are in the second argument
http.get('/user/login', {params: {userName: 'name', password: '123456'}}).then(res => {
// Handle success
}).catch(err => {
// Handle error
})
// Local configuration overrides global configuration
http.get('/user/login', {
params: {userName: 'name', password: '123456'}, /* Appended to the URL */
header: {}, /* Merged with global header, local overrides global */
dataType: 'json',
custom: {auth: true}, // Custom parameters, usable in interceptors
responseType: 'text', // Platform-specific
timeout: 60000, // Platform-specific
sslVerify: true, // Platform-specific
firstIpv4: false, // Platform-specific
withCredentials: false, // Platform-specific
getTask: (task, options) => { /* Callback for task and options */ },
validateStatus: (statusCode) => { /* Custom status code validation */ }
}).then(res => {
// Handle success
}).catch(err => {
// Handle error
})
```
```
--------------------------------
### Install uView Plus via NPM
Source: https://uview-plus.jiangruyi.com/components/install.html
Install uView Plus in your project's root directory using npm. Ensure you have a package.json file; if not, run 'npm init -y' first.
```bash
// If your root directory does not have a package.json file, please run the following command first:
// npm init -y
npm install uview-plus
// Update
// npm update uview-plus
```
--------------------------------
### Using Action Sheet with Setup Script
Source: https://uview-plus.jiangruyi.com/components/quickstart.html
Demonstrates how to use the up-action-sheet component with Vue 3's setup script. The actions are defined as a ref.
```vue
```
--------------------------------
### CateTab Data Setup with Options API
Source: https://uview-plus.jiangruyi.com/components/cateTab.html
Initializes the component data using Vue's Options API. The `list` property holds the data structure for the CateTab component, similar to the Composition API example.
```javascript
export default {
data() {
return {
list: [
{ title: '选项一', children: [
{title: '水煮肉片', cover: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png', price: 88}
]
},
{ title: '选项一', children: [
{title: '酸菜鱼', cover: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png', price: 99}
]
},
{ title: '选项一', children: [
{title: '水煮肉片', cover: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png', price: 88}
]
},
{ title: '选项一', children: [
{title: '酸菜鱼', cover: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png', price: 99}
]
},
]
};
},
methods: {
}
};
```
--------------------------------
### Custom Grid Layout for Icon Applications (Composition API)
Source: https://uview-plus.jiangruyi.com/components/dragsort.html
This example demonstrates a custom grid layout for icon applications using the Composition API with Vue's `
```
--------------------------------
### Signature Component Script Setup
Source: https://uview-plus.jiangruyi.com/components/signature.html
Provides the script setup logic for handling signature capture, including state management for signature images and event handlers for confirmation and errors. This uses the Composition API.
```javascript
import { ref } from 'vue';
const signature1 = ref(null);
const signature2 = ref(null);
const signatureImage1 = ref('');
const signatureImage2 = ref('');
const onConfirm1 = (tempFilePath) => {
signatureImage1.value = tempFilePath;
console.log('签名图片路径1:', tempFilePath);
};
const onError1 = (err) => {
console.error('签名导出错误1:', err);
uni.showToast({
title: '签名导出失败',
icon: 'none'
});
};
const clearSignature1 = () => {
signatureImage1.value = '';
signature1.value.clear();
};
const onConfirm2 = (tempFilePath) => {
signatureImage2.value = tempFilePath;
console.log('签名图片路径2:', tempFilePath);
};
const onError2 = (err) => {
console.error('签名导出错误2:', err);
uni.showToast({
title: '签名导出失败',
icon: 'none'
});
};
const clearSignature2 = () => {
signatureImage2.value = '';
signature2.value.clear();
};
```
--------------------------------
### Basic Guide Component Usage (Vue Options API)
Source: https://uview-plus.jiangruyi.com/components/guide.html
Vue 2 Options API for the Guide component, managing component visibility and onboarding data within the component's data properties.
```javascript
export default {
data() {
return {
show: true,
list: [
{
image: '/static/uview/common/logo.png',
title: '欢迎使用 uview-plus',
desc: '一套跨端可复用的高质量组件库。'
},
{
image: '/static/uview/common/gray-logo.png',
title: '引导页支持多页滑动',
desc: '可配置跳过、下一步和立即体验。'
},
{
image: '/static/uview/common/logo.jpg',
title: '只显示一次',
desc: '默认内置本地存储记忆能力。'
}
]
}
}
}
```
--------------------------------
### Guide Component: Resetting 'Show Once' (Vue Script Setup)
Source: https://uview-plus.jiangruyi.com/components/guide.html
Vue 3 script setup for resetting the Guide component's 'show once' flag. It uses a ref to access the component's methods.
```javascript
import { ref } from 'vue'
const show = ref(false)
const guideRef = ref(null)
function resetGuide() {
guideRef.value?.reset?.()
show.value = true
}
```
--------------------------------
### Basic GoodsSku Setup (Vue)
Source: https://uview-plus.jiangruyi.com/components/goodsSku.html
Sets up the GoodsSku component with basic product information, SKU tree structure, and SKU list. This is the foundational configuration for the component.
```javascript
import { ref } from 'vue';
// 商品信息
const goodsInfo = ref({
image: 'https://picsum.photos/200/200',
price: 99.00,
stock: 100
});
// SKU树形结构
const skuTree = ref([
{
label: '颜色',
name: 'color',
children: [
{ id: 1, name: '红色' },
{ id: 2, name: '蓝色' },
{ id: 3, name: '黑色' }
]
},
{
label: '尺寸',
name: 'size',
children: [
{ id: 1, name: 'S' },
{ id: 2, name: 'M' },
{ id: 3, name: 'L' },
{ id: 4, name: 'XL' }
]
}
]);
// SKU列表
const skuList = ref([
{
id: 1,
color: 1,
size: 1,
price: 99.00,
stock: 50
},
{
id: 2,
color: 1,
size: 2,
price: 99.00,
stock: 40
},
{
id: 3,
color: 2,
size: 1,
price: 109.00,
stock: 30
},
{
id: 4,
color: 2,
size: 3,
price: 109.00,
stock: 20
},
{
id: 5,
color: 3,
size: 4,
price: 89.00,
stock: 60
}
]);
function confirmSku(e) {
uni.showToast({
title: `选择了: ${e.selectedText}, 数量: ${e.num}`,
icon: 'none'
});
}
```
--------------------------------
### Debounce Usage in Vue.js (Script Setup)
Source: https://uview-plus.jiangruyi.com/js/debounce.html
Shows how to implement the debounce function from '@/uni_modules/uview-plus' in a Vue.js script setup. This example demonstrates calling debounce directly in JavaScript.
```vue
露从今夜白
月是故乡明
```
--------------------------------
### Throttle Usage in Vue.js (Script Setup)
Source: https://uview-plus.jiangruyi.com/js/debounce.html
Demonstrates how to use the throttle function imported from '@/uni_modules/uview-plus' within a Vue.js script setup. This example shows calling throttle directly in JavaScript.
```vue
露从今夜白
月是故乡明
```
--------------------------------
### Basic GoodsSku Setup (Vue Options API)
Source: https://uview-plus.jiangruyi.com/components/goodsSku.html
Sets up the GoodsSku component using Vue's Options API with product information, SKU tree, and SKU list. This configuration is an alternative to the Composition API.
```javascript
export default {
data() {
return {
// 商品信息
goodsInfo: {
image: 'https://picsum.photos/200/200',
price: 99.00,
stock: 100
},
// SKU树形结构
skuTree: [
{
label: '颜色',
name: 'color',
children: [
{ id: 1, name: '红色' },
{ id: 2, name: '蓝色' },
{ id: 3, name: '黑色' }
]
},
{
label: '尺寸',
name: 'size',
children: [
{ id: 1, name: 'S' },
{ id: 2, name: 'M' },
{ id: 3, name: 'L' },
{ id: 4, name: 'XL' }
]
}
],
// SKU列表
skuList: [
{
id: 1,
color: 1,
size: 1,
price: 99.00,
stock: 50
},
{
id: 2,
color: 1,
size: 2,
price: 99.00,
stock: 40
},
{
id: 3,
color: 2,
size: 1,
price: 109.00,
stock: 30
},
{
id: 4,
color: 2,
size: 3,
price: 109.00,
stock: 20
},
{
id: 5,
color: 3,
size: 4,
price: 89.00,
stock: 60
}
]
};
},
methods: {
confirmSku(e) {
uni.showToast({
title: `选择了: ${e.selectedText}, 数量: ${e.num}`,
icon: 'none'
});
}
}
};
```
--------------------------------
### Get Current Page Path
Source: https://uview-plus.jiangruyi.com/js/fastUse.html
Retrieves the path of the current page. The returned path starts with a '/'.
```javascript
import { page } from '@/uni_modules/uview-plus';
import { onLoad } from '@dcloudio/uni-app';
onLoad(() => {
// 返回类似/pages/example/components的结果
console.log(page());
});
```
--------------------------------
### Datetime Picker with Min/Max Dates (Vue Script Setup)
Source: https://uview-plus.jiangruyi.com/components/datetimePicker.html
Use the `minDate` and `maxDate` props to set the selectable date range. These props accept timestamps in milliseconds. This example uses Vue's script setup syntax.
```vue
打开
```
--------------------------------
### 基本使用 - Script Setup
Source: https://uview-plus.jiangruyi.com/components/notify.html
使用 ref 创建响应式数据来控制 Notify 组件的显示状态。
```javascript
import { ref } from 'vue';
// 创建响应式数据
const show = ref(true);
```
--------------------------------
### Basic Usage
Source: https://uview-plus.jiangruyi.com/components/keyboard.html
Demonstrates how to use the basic keyboard component, controlling its visibility with the `show` prop and setting the keyboard mode.
```APIDOC
## Basic Usage
This example shows how to integrate the `up-keyboard` component into your application. The `mode` prop defines the keyboard type (e.g., 'car', 'number', 'card'), and the `show` prop, bound to a boolean variable, controls the keyboard's visibility.
### Component Usage
```vue
打开
```
### Vue 2 Example
```vue
打开
```
```
--------------------------------
### Disable Dragging for Specific Items (Composition API)
Source: https://uview-plus.jiangruyi.com/components/dragsort.html
This example demonstrates disabling specific items using the Composition API with Vue's `