diff --git a/.vscode/extensions.json b/.vscode/extensions.json index dca65e1..1312a24 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ "Vue.volar", - "Vue.vscode-typescript-vue-plugin", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "stylelint.vscode-stylelint" diff --git a/CHANGELOG.md b/CHANGELOG.md index fa90dbd..85ff3a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.0.2](https://github.com/zero-one-code/vue-default-page/compare/v1.0.1...v1.0.2) (2024-06-01) + + +### Bug Fixes + +* the inaccuracy in height retrieval ([0711dc9](https://github.com/zero-one-code/vue-default-page/commit/0711dc9605fa4328f5984cf78232cbe66148cd9e)) + ## [1.0.1](https://github.com/zero-one-code/vue-default-page/compare/v1.0.0...v1.0.1) (2024-02-20) diff --git a/README.md b/README.md index 2779127..df7feb2 100644 --- a/README.md +++ b/README.md @@ -2,38 +2,43 @@ English | [中文](./README.zh-CN.md) # Vue-Default-Page -A Vue 3.0 custom directives plugin, with built-in directives such as `v-loading`, `v-skeleton`, `v-skeleton-avatar`, `v-skeleton-list`, `v-error`, and `v-empty`, dedicated to addressing issues related to waiting, feedback, and error during network requests. +[![NPM Version](https://img.shields.io/npm/v/vue-default-page)](https://www.npmjs.com/package/vue-default-page) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/edit/vue-default-page?file=src%2FApp.vue) -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vue-default-page?file=src%2FApp.vue) +A Vue 3.0 custom directives plugin package, built-in with `v-loading`, `v-skeleton`, `v-skeleton-avatar`, `v-skeleton-list`, `v-error`, and `v-empty` default page directives, focusing on solving scenarios such as waiting, feedback, and error during network requests. ## Table of Contents - [Installation](#installation) - [Quickstart](#quickstart) + - [Full Import](#full-import) + - [Global Configuration](#global-configuration) + - [On-demand Import](#on-demand-import) + - [On-demand Import Global Configuration](#on-demand-import-global-configuration) + - [Partial Import](#partial-import) + - [Partial Import Configuration](#partial-import-configuration) - [Advanced](#advanced) - [Show Priority](#show-priority) -- [Custom Options](#custom-options) - - [Common Options](#common-options) - - [Common Attribute Options](#common-attribute-options) - [v-loading](#v-loading) - - [Options](#options) - - [Attribute Options](#attribute-options) + - [VdpLoading](#vdploading) + - [Attribute Configurations](#attribute-configurations) - [v-skeleton](#v-skeleton) - - [Options](#options-1) - - [Attribute Options](#attribute-options-1) + - [VdpSkeleton](#vdpskeleton) + - [Attribute Configurations](#attribute-configurations-1) - [Animation](#animation) - - [v-skeleton-avatar Options](#v-skeleton-avatar-options) - - [v-skeleton-list Options](#v-skeleton-list-options) + - [VdpSkeletonAvatar](#vdpskeletonavatar) + - [VdpSkeletonList](#vdpskeletonlist) - [v-error](#v-error) - - [Options](#options-2) - - [Attribute Options](#attribute-options-2) + - [VdpError](#vdperror) + - [Attribute Configurations](#attribute-configurations-2) - [v-empty](#v-empty) - - [Options](#options-3) - - [Attribute Options](#attribute-options-3) + - [VdpEmpty](#vdpempty) + - [Attribute Configurations](#attribute-configurations-3) - [Adapt to Mobile](#adapt-to-mobile) - [Thanks](#thanks) - [LICENSE](#license) + ## Installation ```sh @@ -42,6 +47,8 @@ npm i vue-default-page ## Quickstart +### Full Import + ```js // main.js @@ -64,13 +71,41 @@ app.use(vueDefaultPage);
``` -Import a single directive. +### Global Configuration + +```js +// main.js + +app.use(vueDefaultPage, { + background: '#000', + loading: { + iconColor: '#fff', + miniIconColor: '#fff', + textColor: '#fff', + }, +}); +``` + +| Name | Description | Type | Default | +| -------------- | -------------------------------- | ------------------------------------------------- | ------- | +| zIndex | The stack level of the directive | number / string | 100 | +| background | Background color of the mask | string | #fff | +| loading | v-loading configurations | boolean / [VdpLoading](#vdploading) | true | +| skeleton | v-skeleton configurations | boolean / [VdpSkeleton](#vdpskeleton) | true | +| skeletonAvatar | v-skeleton-avatar configurations | boolean / [VdpSkeletonAvatar](#vdpskeletonavatar) | false | +| skeletonList | v-skeleton-list configurations | boolean / [VdpSkeletonList](#vdpskeletonlist) | false | +| error | v-error configurations | boolean / [VdpError](#vdperror) | true | +| empty | v-empty configurations | boolean / [VdpEmpty](#vdpempty) | true | + +### On-demand Import ```js // main.js // Import the directive import { vdpLoading } from 'vue-default-page'; +// Import the style +import 'vue-default-page/index.css'; import { createApp } from 'vue'; @@ -80,112 +115,56 @@ const app = createApp(); app.use(vdpLoading); ``` -Import to the component. +### On-demand Import Global Configuration -```vue - - - +```js +// main.js - +app.use(vdpLoading, { + background: '#000', + iconColor: '#fff', + miniIconColor: '#fff', + textColor: '#fff', +}); ``` -### Advanced +| Name | Description | Configurations Type | +| ----------------- | ----------------- | --------------------------------------- | +| vdpLoading | v-loading | [VdpLoading](#vdploading) | +| vdpSkeleton | v-skeleton | [VdpSkeleton](#vdpskeleton) | +| vdpSkeletonAvatar | v-skeleton-avatar | [VdpSkeletonAvatar](#vdpskeletonavatar) | +| vdpSkeletonList | v-skeleton-list | [VdpSkeletonList](#vdpskeletonlist) | +| vdpError | v-error | [VdpError](#vdperror) | +| vdpEmpty | v-empty | [VdpEmpty](#vdpempty) | + +### Partial Import ```vue ``` -### Show Priority - -When all directives are true, it will be shown according to the following priority. - -`v-loading` > `v-skeleton` = `v-skeleton-avatar` = `v-skeleton-list` > `v-error` > `v-empty` - -## Custom Options +### Partial Import Configuration -```js -// main.js - -app.use(vueDefaultPage, { - background: '#000', - loading: { - iconColor: '#fff', - miniIconColor: '#fff', - textColor: '#fff', - }, -}); -``` - -Set options when import a single directive. - -```js -// main.js - -app.use(vdpLoading, { - background: '#000', - iconColor: '#fff', - miniIconColor: '#fff', - textColor: '#fff', -}); -``` - -Set options when import to the component. +Method 1: Configure in the directives creation function, the detailed configurations is consistent with [On-demand Import Global Configuration](#on-demand-import-global-configuration). ```vue + + ``` -Set options through attributes on the element. +Method 2: Add attribute configurations to the element. ```vue @@ -211,33 +194,55 @@ Set options through attributes on the element. ``` -Set a boolean to disable directive you don't wish to register. +Common attribute configurations, for specific directive attribute configurations, please refer to the detailed sections below. -```js -// main.js +| Name | Description | Type | Default | +| -------------- | -------------------------------- | ------ | ------- | +| vdp-z-index | The stack level of the directive | string | 100 | +| vdp-background | Background color of the mask | string | #fff | -app.use(vueDefaultPage, { - error: false, -}); -``` +### Advanced -### Common Options +```vue + -| Name | Description | Type | Default | -| ---------- | -------------------------------- | --------------- | ------- | -| zIndex | the stack level of the directive | number / string | 100 | -| background | background color of the mask | string | #fff | + + + +``` + +### Show Priority + +When all directives are true, it will be shown according to the following priority. + +`v-loading` > `v-skeleton` = `v-skeleton-avatar` = `v-skeleton-list` > `v-error` > `v-empty` ## v-loading -Custom icon, same option as [v-error](#v-error) and [v-empty](#v-empty). +Custom icon, same configuration as [v-error](#v-error) and [v-empty](#v-empty). ```vue @@ -277,33 +282,33 @@ Custom icon, same option as [v-error](#v-error) and [v-empty](#v-empty). ``` -### Options +### VdpLoading -| Name | Description | Type | Default | -| ------------- | ----------------------------------------------- | ---------------- | -------- | -| enable | enable the directive | boolean | true | -| text | text | string | Loading… | -| textColor | text color | string | #999 | -| iconColor | icon color (disable when custom icon) | string | #bbb | -| miniIconColor | mini icon color (disable when custom mini icon) | string | #bbb | -| icon | custom icon | string | — | -| miniIcon | custom mini icon | boolean / string | true | -| iconMaxSize | maximum size of icon | number / string | 24 | -| iconShowText | whether to show text when using large icon | boolean | true | -| zIndex | the stack level of the directive | number / string | 100 | -| background | background color of the mask | string | #fff | +| Name | Description | Type | Default | +| ------------- | -------------------------------------------------------------------------------- | ---------------- | -------- | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | true | +| text | Text | string | Loading… | +| textColor | Text color | string | #999 | +| iconColor | Icon color (Disable when custom icon) | string | #bbb | +| miniIconColor | Mini icon color (Disable when custom mini icon) | string | #bbb | +| icon | Custom icon | string | — | +| miniIcon | Custom mini icon | boolean / string | true | +| iconMaxSize | Maximum size of icon | number / string | 24 | +| iconShowText | Whether to show text when using large icon | boolean | true | +| zIndex | The stack level of the directive | number / string | 100 | +| background | Background color of the mask | string | #fff | -### Attribute Options +### Attribute Configurations | Name | Description | Type | Default | | --------------------------- | ---------------------------------------------- | ------ | -------- | -| vdp-loading-text | text | string | Loading… | -| vdp-loading-text-color | text color | string | #999 | -| vdp-loading-icon-color | icon color (disable when custom icon) | string | #bbb | -| vdp-loading-mini-icon-color | mini icon color (disable when custom mini ico) | string | #bbb | -| vdp-loading-icon | custom icon | string | — | -| vdp-loading-mini-icon | custom mini icon | string | — | -| vdp-loading-icon-max-size | maximum size of icon | string | 24 | +| vdp-loading-text | Text | string | Loading… | +| vdp-loading-text-color | Text color | string | #999 | +| vdp-loading-icon-color | Icon color (Disable when custom icon) | string | #bbb | +| vdp-loading-mini-icon-color | Mini icon color (Disable when custom mini ico) | string | #bbb | +| vdp-loading-icon | Custom icon | string | — | +| vdp-loading-mini-icon | Custom mini icon | string | — | +| vdp-loading-icon-max-size | Maximum size of icon | string | 24 | ## v-skeleton @@ -319,7 +324,30 @@ Default show avatar and list skeleton, can also be used independently. ``` -These two directives can be used independently by registering them. Unlike other directives, they are false by default and need to be manually activated. +### VdpSkeleton + +| Name | Description | Type | Default | +| ------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------- | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | true | +| animation | Animation | boolean / ('avatar' | 'list')[] / [Animation](#animation) | true | +| avatarMaxSize | Maximum size of avatar | number / string | 54 | +| zIndex | The stack level of the directive | number / string | 100 | +| background | Background color of the mask | string | #fff | + +### Attribute Configurations + +| Name | Description | Type | Default | +| ---------------------------- | ---------------------- | ------ | ------- | +| vdp-skeleton-avatar-max-size | Maximum size of avatar | string | 54 | + +### Animation + +| Name | Description | Type | Default | +| ------ | ----------------------- | ------- | ------- | +| avatar | Enable avatar animation | boolean | true | +| list | Enable list animation | boolean | true | + +Avatar or list skeleton can also be used individually by registering directives, but unlike other directives, these two are `false` by default and need to be manually enabled. ```js // main.js @@ -339,47 +367,24 @@ app.use(vueDefaultPage, { ``` -### Options - -| Name | Description | Type | Default | -| ------------- | -------------------------------- | -------------------------------------------- | ------- | -| enable | enable the directive | boolean | true | -| animation | animation | boolean / ('avatar' | 'list')[] / Animation | true | -| avatarMaxSize | maximum size of avatar | number / string | 54 | -| zIndex | the stack level of the directive | number / string | 100 | -| background | background color of the mask | string | #fff | - -### Attribute Options - -| Name | Description | Type | Default | -| ---------------------------- | ---------------------- | ------ | ------- | -| vdp-skeleton-avatar-max-size | maximum size of avatar | string | 54 | - -### Animation - -| Name | Description | Type | Default | -| ------ | ----------- | ------- | ------- | -| avatar | show avatar | boolean | true | -| list | show list | boolean | true | - -### v-skeleton-avatar Options +### VdpSkeletonAvatar -| Name | Description | Type | Default | -| ------------- | ---------------------- | --------------- | ------- | -| enable | enable the directive | boolean | false | -| animation | animation | boolean | true | -| avatarMaxSize | maximum size of avatar | number / string | 54 | +| Name | Description | Type | Default | +| ------------- | -------------------------------------------------------------------------------- | --------------- | ------- | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | false | +| animation | Animation | boolean | true | +| avatarMaxSize | Maximum size of avatar | number / string | 54 | -### v-skeleton-list Options +### VdpSkeletonList -| Name | Description | Type | Default | -| --------- | -------------------- | ------- | ------- | -| enable | enable the directive | boolean | false | -| animation | animation | boolean | true | +| Name | Description | Type | Default | +| --------- | -------------------------------------------------------------------------------- | ------- | ------- | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | false | +| animation | Animation | boolean | true | ## v-error -Like other directives, it can be controlled to show or hide using a boolean. +Like other directives, it can be controlled to show or hide using a Boolean. ```vue @@ -389,7 +394,7 @@ Like other directives, it can be controlled to show or hide using a boolean. ``` -You can also pass a refresh function in an array. For detailed usage, refer to [Advanced](#Advanced). +You can also pass a refresh function in an Array. For detailed usage, refer to [Advanced](#advanced). ```vue @@ -399,35 +404,35 @@ You can also pass a refresh function in an array. For detailed usage, refer to [ ``` -### Options +### VdpError -| Name | Description | Type | Default | -| ------------ | ----------------------------------------------------- | ---------------- | ------------------ | -| enable | enable the directive | boolean | true | -| text | text | string | Network Error | -| refreshText | refresh text (enable when refresh function is passed) | boolean / string | , Click to Refresh | -| textColor | text color | string | #999 | -| icon | custom icon | string | — | -| miniIcon | custom mini icon | boolean / string | true | -| iconMaxSize | maximum size of icon | number / string | 180 | -| iconShowText | whether to show text when using large icon | boolean | true | -| zIndex | the stack level of the directive | number / string | 100 | -| background | background color of the mask | string | #fff | +| Name | Description | Type | Default | +| ------------ | -------------------------------------------------------------------------------- | ---------------- | ------------------ | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | true | +| text | Text | string | Network Error | +| refreshText | Refresh text (Enable when refresh function is passed) | boolean / string | , Click to Refresh | +| textColor | Text color | string | #999 | +| icon | Custom icon | string | — | +| miniIcon | Custom mini icon | boolean / string | true | +| iconMaxSize | Maximum size of icon | number / string | 180 | +| iconShowText | Whether to show text when using large icon | boolean | true | +| zIndex | The stack level of the directive | number / string | 100 | +| background | Background color of the mask | string | #fff | -### Attribute Options +### Attribute Configurations | Name | Description | Type | Default | | ----------------------- | ----------------------------------------------------- | ------ | ------------------ | -| vdp-error-text | text | string | Network Error | -| vdp-error-refresh-text | refresh text (enable when refresh function is passed) | string | , Click to Refresh | -| vdp-error-text-color | text color | string | #999 | -| vdp-error-icon | custom icon | string | — | -| vdp-error-mini-icon | custom mini icon | string | — | -| vdp-error-icon-max-size | maximum size of icon | string | 180 | +| vdp-error-text | Text | string | Network Error | +| vdp-error-refresh-text | Refresh text (Enable when refresh function is passed) | string | , Click to Refresh | +| vdp-error-text-color | Text color | string | #999 | +| vdp-error-icon | Custom icon | string | — | +| vdp-error-mini-icon | Custom mini icon | string | — | +| vdp-error-icon-max-size | Maximum size of icon | string | 180 | ## v-empty -All directives will automatically adjust their height according to the container's size, and exhibit varying display states. +All directives will automatically adjust their height according to the container's size, and they have different display states. ```vue @@ -452,29 +457,29 @@ The maximum icon size can be adjusted using the `iconMaxSize` or the `vdp-empty- ``` -### Options +### VdpEmpty -| Name | Description | Type | Default | -| ------------ | ------------------------------------- | ---------------- | ------- | -| enable | enable the directive | boolean | true | -| text | text | string | No Data | -| textColor | text color | string | #999 | -| icon | custom icon | string | — | -| miniIcon | custom mini icon | boolean / string | true | -| iconMaxSize | maximum size of icon | number / string | 180 | -| iconShowText | whether to show text when using large | boolean | true | -| zIndex | the stack level of the directive | number / string | 100 | -| background | background color of the mask | string | #fff | +| Name | Description | Type | Default | +| ------------ | -------------------------------------------------------------------------------- | ---------------- | ------- | +| enable | Enable the directive (Enable when [Global Configuration](#global-configuration)) | boolean | true | +| text | Text | string | No Data | +| textColor | Text color | string | #999 | +| icon | Custom icon | string | — | +| miniIcon | Custom mini icon | boolean / string | true | +| iconMaxSize | Maximum size of icon | number / string | 180 | +| iconShowText | Whether to show text when using large | boolean | true | +| zIndex | The stack level of the directive | number / string | 100 | +| background | Background color of the mask | string | #fff | -### Attribute Options +### Attribute Configurations | Name | Description | Type | Default | | ----------------------- | -------------------- | ------ | ------- | -| vdp-empty-text | text | string | No Data | -| vdp-empty-text-color | text color | string | #999 | -| vdp-empty-icon | custom icon | string | — | -| vdp-empty-mini-icon | custom mini icon | string | — | -| vdp-empty-icon-max-size | maximum size of icon | string | 180 | +| vdp-empty-text | Text | string | No Data | +| vdp-empty-text-color | Text color | string | #999 | +| vdp-empty-icon | Custom icon | string | — | +| vdp-empty-mini-icon | Custom mini icon | string | — | +| vdp-empty-icon-max-size | Maximum size of icon | string | 180 | ## Adapt to Mobile diff --git a/README.zh-CN.md b/README.zh-CN.md index 488f5fb..b78e1e1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,32 +1,36 @@ # Vue-Default-Page -一个 Vue 3.0 自定义指令包插件,内置 `v-loading`,`v-skeleton`,`v-skeleton-avatar`,`v-skeleton-list`,`v-error`,`v-empty` 等指令,专注解决网络请求时等待、回显和报错等场景。 +[![NPM Version](https://img.shields.io/npm/v/vue-default-page)](https://www.npmjs.com/package/vue-default-page) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/edit/vue-default-page?file=src%2FApp.vue) -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vue-default-page?file=src%2FApp.vue) +一个 Vue 3.0 自定义指令包插件,内置 `v-loading`,`v-skeleton`,`v-skeleton-avatar`,`v-skeleton-list`,`v-error`,`v-empty` 等缺省页指令,专注解决网络请求时等待、回显和报错等场景。 ## 目录 - [安装](#安装) - [快速上手](#快速上手) + - [完整引入](#完整引入) + - [全局配置](#全局配置) + - [按需引入](#按需引入) + - [按需引入全局配置](#按需引入全局配置) + - [局部引入](#局部引入) + - [局部引入配置](#局部引入配置) - [进阶](#进阶) - [显示优先级](#显示优先级) -- [自定义配置](#自定义配置) - - [通用配置项](#通用配置项) - - [属性通用配置项](#属性通用配置项) - [v-loading](#v-loading) - - [配置项](#配置项) + - [VdpLoading 配置项](#vdploading-配置项) - [属性配置项](#属性配置项) - [v-skeleton](#v-skeleton) - - [配置项](#配置项-1) + - [VdpSkeleton 配置项](#vdpskeleton-配置项) - [属性配置项](#属性配置项-1) - [Animation](#animation) - - [v-skeleton-avatar 配置项](#v-skeleton-avatar-配置项) - - [v-skeleton-list 配置项](#v-skeleton-list-配置项) + - [VdpSkeletonAvatar 配置项](#vdpskeletonavatar-配置项) + - [VdpSkeletonList 配置项](#vdpskeletonlist-配置项) - [v-error](#v-error) - - [配置项](#配置项-2) + - [VdpError 配置项](#vdperror-配置项) - [属性配置项](#属性配置项-2) - [v-empty](#v-empty) - - [配置项](#配置项-3) + - [VdpEmpty 配置项](#vdpempty-配置项) - [属性配置项](#属性配置项-3) - [兼容移动端](#兼容移动端) - [鸣谢](#鸣谢) @@ -40,6 +44,8 @@ npm i vue-default-page ## 快速上手 +### 完整引入 + ```js // main.js @@ -62,13 +68,41 @@ app.use(vueDefaultPage);
``` -单独使用某个指令。 +### 全局配置 + +```js +// main.js + +app.use(vueDefaultPage, { + background: '#000', + loading: { + iconColor: '#fff', + miniIconColor: '#fff', + textColor: '#fff', + }, +}); +``` + +| 名称 | 说明 | 类型 | 默认值 | +| -------------- | -------------------------- | -------------------------------------------------------- | ------ | +| zIndex | 指令的层叠顺序 | number / string | 100 | +| background | 背景遮罩的颜色 | string | #fff | +| loading | v-loading 指令配置 | boolean / [VdpLoading](#vdploading-配置项) | true | +| skeleton | v-skeleton 指令配置 | boolean / [VdpSkeleton](#vdpskeleton-配置项) | true | +| skeletonAvatar | v-skeleton-avatar 指令配置 | boolean / [VdpSkeletonAvatar](#vdpskeletonavatar-配置项) | false | +| skeletonList | v-skeleton-list 指令配置 | boolean / [VdpSkeletonList](#vdpskeletonlist-配置项) | false | +| error | v-error 指令配置 | boolean / [VdpError](#vdperror-配置项) | true | +| empty | v-empty 指令配置 | boolean / [VdpEmpty](#vdpempty-配置项) | true | + +### 按需引入 ```js // main.js // 引入指令 import { vdpLoading } from 'vue-default-page'; +// 引入样式 +import 'vue-default-page/index.css'; import { createApp } from 'vue'; @@ -78,112 +112,56 @@ const app = createApp(); app.use(vdpLoading); ``` -直接在组件中引入。 - -```vue - +### 按需引入全局配置 - +```js +// main.js - +app.use(vdpLoading, { + background: '#000', + iconColor: '#fff', + miniIconColor: '#fff', + textColor: '#fff', +}); ``` -### 进阶 +| 名称 | 说明 | 配置项类型 | +| ----------------- | ---------------------- | ---------------------------------------------- | +| vdpLoading | v-loading 指令 | [VdpLoading](#vdploading-配置项) | +| vdpSkeleton | v-skeleton 指令 | [VdpSkeleton](#vdpskeleton-配置项) | +| vdpSkeletonAvatar | v-skeleton-avatar 指令 | [VdpSkeletonAvatar](#vdpskeletonavatar-配置项) | +| vdpSkeletonList | v-skeleton-list 指令 | [VdpSkeletonList](#vdpskeletonlist-配置项) | +| vdpError | v-error 指令 | [VdpError](#vdperror-配置项) | +| vdpEmpty | v-empty 指令 | [VdpEmpty](#vdpempty-配置项) | + +### 局部引入 ```vue ``` -### 显示优先级 - -指令均为 true 时会按以下优先级显示。 - -`v-loading` > `v-skeleton` = `v-skeleton-avatar` = `v-skeleton-list` > `v-error` > `v-empty` - -## 自定义配置 - -```js -// main.js - -app.use(vueDefaultPage, { - background: '#000', - loading: { - iconColor: '#fff', - miniIconColor: '#fff', - textColor: '#fff', - }, -}); -``` - -单独使用某个指令时添加配置。 +### 局部引入配置 -```js -// main.js - -app.use(vdpLoading, { - background: '#000', - iconColor: '#fff', - miniIconColor: '#fff', - textColor: '#fff', -}); -``` - -在组件中引入时添加配置。 +方法一:在指令创建方法中配置,具体配置与[按需引入全局配置](#按需引入全局配置)一致。 ```vue + + ``` -通过在元素上添加属性配置。 +方法二:在元素上添加属性配置。 ```vue @@ -209,29 +191,51 @@ app.use(vdpLoading, { ``` -直接传布尔值关闭不想要的指令。 +通用属性配置项,各指令属性配置项请前往下方具体章节查看。 -```js -// main.js +| 名称 | 说明 | 类型 | 默认值 | +| -------------- | -------------- | ------ | ------ | +| vdp-z-index | 指令的层叠顺序 | string | 100 | +| vdp-background | 背景遮罩的颜色 | string | #fff | -app.use(vueDefaultPage, { - error: false, -}); -``` +### 进阶 + +```vue + + + -| 名称 | 说明 | 类型 | 默认值 | -| ---------- | -------------- | --------------- | ------ | -| zIndex | 指令的层叠顺序 | number / string | 100 | -| background | 背景遮罩的颜色 | string | #fff | + +``` -### 属性通用配置项 +### 显示优先级 -| 名称 | 说明 | 类型 | 默认值 | -| -------------- | -------------- | ------ | ------ | -| vdp-z-Index | 指令的层叠顺序 | string | 100 | -| vdp-background | 背景遮罩的颜色 | string | #fff | +指令均为 true 时会按以下优先级显示。 + +`v-loading` > `v-skeleton` = `v-skeleton-avatar` = `v-skeleton-list` > `v-error` > `v-empty` ## v-loading @@ -275,21 +279,21 @@ app.use(vueDefaultPage, { ``` -### 配置项 - -| 名称 | 说明 | 类型 | 默认值 | -| ------------- | -------------------------------- | ---------------- | -------- | -| enable | 是否使用指令 | boolean | true | -| text | 文案 | string | Loading… | -| textColor | 文案颜色 | string | #999 | -| iconColor | 图标颜色(自定义图标时失效) | string | #bbb | -| miniIconColor | 小图标颜色(自定义小图标时失效) | string | #bbb | -| icon | 自定义图标 | string | — | -| miniIcon | 自定义小图标 | boolean / string | true | -| iconMaxSize | 图标最大尺寸 | number / string | 24 | -| iconShowText | 大图标时是否显示文案 | boolean | true | -| zIndex | 指令的层叠顺序 | number / string | 100 | -| background | 背景遮罩的颜色 | string | #fff | +### VdpLoading 配置项 + +| 名称 | 说明 | 类型 | 默认值 | +| ------------- | ----------------------------------------------- | ---------------- | -------- | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | true | +| text | 文案 | string | Loading… | +| textColor | 文案颜色 | string | #999 | +| iconColor | 图标颜色(自定义图标时失效) | string | #bbb | +| miniIconColor | 小图标颜色(自定义小图标时失效) | string | #bbb | +| icon | 自定义图标 | string | — | +| miniIcon | 自定义小图标 | boolean / string | true | +| iconMaxSize | 图标最大尺寸 | number / string | 24 | +| iconShowText | 大图标时是否显示文案 | boolean | true | +| zIndex | 指令的层叠顺序 | number / string | 100 | +| background | 背景遮罩的颜色 | string | #fff | ### 属性配置项 @@ -305,7 +309,7 @@ app.use(vueDefaultPage, { ## v-skeleton -默认显示头像和列表 skeleton, 也可以单独使用。 +默认显示头像和列表 skeleton,也可以单独使用。 ```vue @@ -317,7 +321,30 @@ app.use(vueDefaultPage, { ``` -可以通过定义指令的形式单独使用,与其他指令不同的是这两个指令默认是关闭的,需手动开启。 +### VdpSkeleton 配置项 + +| 名称 | 说明 | 类型 | 默认值 | +| ------------- | ----------------------------------------------- | ---------------------------------------------------------- | ------ | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | true | +| animation | 动画 | boolean / ('avatar' | 'list')[] / [Animation](#animation) | true | +| avatarMaxSize | 头像最大尺寸 | number / string | 54 | +| zIndex | 指令的层叠顺序 | number / string | 100 | +| background | 背景遮罩的颜色 | string | #fff | + +### 属性配置项 + +| 名称 | 说明 | 类型 | 默认值 | +| ---------------------------- | ------------ | ------ | ------ | +| vdp-skeleton-avatar-max-size | 头像最大尺寸 | string | 54 | + +### Animation + +| 名称 | 说明 | 类型 | 默认值 | +| ------ | ------------ | ------- | ------ | +| avatar | 开启头像动画 | boolean | true | +| list | 开启列表动画 | boolean | true | + +头像或列表 skeleton 也可以通过定义指令的形式单独使用,但与其他指令不同的是这两个指令默认是关闭的,需手动开启。 ```js // main.js @@ -337,43 +364,20 @@ app.use(vueDefaultPage, { ``` -### 配置项 - -| 名称 | 说明 | 类型 | 默认值 | -| ------------- | -------------- | -------------------------------------------- | ------ | -| enable | 是否使用指令 | boolean | true | -| animation | 动画 | boolean / ('avatar' | 'list')[] / Animation | true | -| avatarMaxSize | 头像最大尺寸 | number / string | 54 | -| zIndex | 指令的层叠顺序 | number / string | 100 | -| background | 背景遮罩的颜色 | string | #fff | - -### 属性配置项 - -| 名称 | 说明 | 类型 | 默认值 | -| ---------------------------- | ------------ | ------ | ------ | -| vdp-skeleton-avatar-max-size | 头像最大尺寸 | string | 54 | - -### Animation - -| 名称 | 说明 | 类型 | 默认值 | -| ------ | -------- | ------- | ------ | -| avatar | 显示头像 | boolean | true | -| list | 显示列表 | boolean | true | - -### v-skeleton-avatar 配置项 +### VdpSkeletonAvatar 配置项 -| 名称 | 说明 | 类型 | 默认值 | -| ------------- | ------------ | --------------- | ------ | -| enable | 是否使用指令 | boolean | false | -| animation | 动画 | boolean | true | -| avatarMaxSize | 头像最大尺寸 | number / string | 54 | +| 名称 | 说明 | 类型 | 默认值 | +| ------------- | ----------------------------------------------- | --------------- | ------ | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | false | +| animation | 动画 | boolean | true | +| avatarMaxSize | 头像最大尺寸 | number / string | 54 | -### v-skeleton-list 配置项 +### VdpSkeletonList 配置项 -| 名称 | 说明 | 类型 | 默认值 | -| --------- | ------------ | ------- | ------ | -| enable | 是否使用指令 | boolean | false | -| animation | 动画 | boolean | true | +| 名称 | 说明 | 类型 | 默认值 | +| --------- | ----------------------------------------------- | ------- | ------ | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | false | +| animation | 动画 | boolean | true | ## v-error @@ -397,20 +401,20 @@ app.use(vueDefaultPage, { ``` -### 配置项 - -| 名称 | 说明 | 类型 | 默认值 | -| ------------ | ------------------------------ | ---------------- | ------------------ | -| enable | 是否使用指令 | boolean | true | -| text | 文案 | string | Network Error | -| refreshText | 刷新文案(传入刷新函数时生效) | boolean / string | , Click to Refresh | -| textColor | 文案颜色 | string | #999 | -| icon | 自定义图标 | string | — | -| miniIcon | 自定义小图标 | boolean / string | true | -| iconMaxSize | 图标最大尺寸 | number / string | 180 | -| iconShowText | 大图标时是否显示文案 | boolean | true | -| zIndex | 指令的层叠顺序 | number / string | 100 | -| background | 背景遮罩的颜色 | string | #fff | +### VdpError 配置项 + +| 名称 | 说明 | 类型 | 默认值 | +| ------------ | ----------------------------------------------- | ---------------- | ------------------ | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | true | +| text | 文案 | string | Network Error | +| refreshText | 刷新文案(传入刷新函数时生效) | boolean / string | , Click to Refresh | +| textColor | 文案颜色 | string | #999 | +| icon | 自定义图标 | string | — | +| miniIcon | 自定义小图标 | boolean / string | true | +| iconMaxSize | 图标最大尺寸 | number / string | 180 | +| iconShowText | 大图标时是否显示文案 | boolean | true | +| zIndex | 指令的层叠顺序 | number / string | 100 | +| background | 背景遮罩的颜色 | string | #fff | ### 属性配置项 @@ -450,19 +454,19 @@ app.use(vueDefaultPage, { ``` -### 配置项 - -| 名称 | 说明 | 类型 | 默认值 | -| ------------ | -------------------- | ---------------- | ------- | -| enable | 是否使用指令 | boolean | true | -| text | 文案 | string | No Data | -| textColor | 文案颜色 | string | #999 | -| icon | 自定义图标 | string | — | -| miniIcon | 自定义小图标 | boolean / string | true | -| iconMaxSize | 图标最大尺寸 | number / string | 180 | -| iconShowText | 大图标时是否显示文案 | boolean | true | -| zIndex | 指令的层叠顺序 | number / string | 100 | -| background | 背景遮罩的颜色 | string | #fff | +### VdpEmpty 配置项 + +| 名称 | 说明 | 类型 | 默认值 | +| ------------ | ----------------------------------------------- | ---------------- | ------- | +| enable | 是否使用指令(仅在[全局配置](#全局配置)时生效) | boolean | true | +| text | 文案 | string | No Data | +| textColor | 文案颜色 | string | #999 | +| icon | 自定义图标 | string | — | +| miniIcon | 自定义小图标 | boolean / string | true | +| iconMaxSize | 图标最大尺寸 | number / string | 180 | +| iconShowText | 大图标时是否显示文案 | boolean | true | +| zIndex | 指令的层叠顺序 | number / string | 100 | +| background | 背景遮罩的颜色 | string | #fff | ### 属性配置项 diff --git a/package.json b/package.json index fa78a22..09c02d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-default-page", - "version": "1.0.1", + "version": "1.0.2", "description": "A Vue 3.0 custom directives plugin", "keywords": [ "vue", diff --git a/src/components/picture.vue b/src/components/picture.vue index 40870fa..53cc963 100644 --- a/src/components/picture.vue +++ b/src/components/picture.vue @@ -1,6 +1,7 @@