Skip to content

Commit 9e64820

Browse files
committed
docs: add en and zh configure load msg page
1 parent 5587028 commit 9e64820

File tree

5 files changed

+124
-4
lines changed

5 files changed

+124
-4
lines changed

docs/.vuepress/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
'',
3232
'start-with-hn',
3333
'use-with-filter-or-tabs',
34+
'configure-load-msg',
3435
'configure-plugin-opts',
3536
],
3637
},
@@ -67,6 +68,7 @@ module.exports = {
6768
'',
6869
'start-with-hn',
6970
'use-with-filter-or-tabs',
71+
'configure-load-msg',
7072
'configure-plugin-opts',
7173
],
7274
},

docs/api/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ sidebar: auto
66

77
## Props
88

9-
The default value for these properties can be overridden through the Plugin API.
9+
The default value for most of properties can be overridden through the Plugin API.
10+
11+
- See also: [Configure Plugin Options - Props/Settings](../guide/configure-plugin-opts.md#props-settings)
1012

1113
### distance
1214

@@ -23,7 +25,7 @@ The `infinite` event will be fired if the scroll distance is less than this valu
2325
- Available: `default` | `spiral` | `circles` | `bubbles` | `waveDots`
2426
- Details:
2527

26-
This property is used to set the loading animation, you can choose one from the internal spinners that you like, you can also customize it with a [named slot](https://vuejs.org/v2/guide/components.html#Named-Slots) that called `spinner`.
28+
This property is used to set the loading animation, you can choose one from the internal spinners that you like, you can also customize it with a [named slot](#spinner-2) that called `spinner`.
2729

2830
### direction
2931

@@ -56,6 +58,10 @@ The comopnent will be reset if this property has changed, just like recreating a
5658

5759
The contents for these slots can be configured via the [`slot` special attribute](https://vuejs.org/v2/api/index.html#slot), also can be configure via the plugin API.
5860

61+
- See also:
62+
- [Configure Load Messages](../guide/configure-load-msg.md)
63+
- [Configure Plugin Options - Slots](../guide/configure-plugin-opts.md#slots)
64+
5965
### no-results
6066

6167
- Default: `No results :(`

docs/guide/configure-load-msg.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Configure Load Messages
2+
3+
This component provide four different slots use to display different load messages: `spinner`, `no-more`, `no-results`, `error`, you can read more about it in [here](../api/#slots).
4+
5+
## Via `slot` Sepcial Attribute
6+
7+
We can use the [`slot` special attribute](https://vuejs.org/v2/api/index.html#slot) to configure them:
8+
9+
``` html
10+
<infinite-loading>
11+
<div slot="spinner">Loading...</div>
12+
<div slot="no-more">No more message</div>
13+
<div slot="no-results">No results message</div>
14+
</infinite-loading>
15+
```
16+
17+
Unlike other slots, the default value for the `error` slot will provide a retry button for users to load data again. If you want to impletement a retry button for users when you customize the `error` slot, you can use the [`slot-scope`](https://vuejs.org/v2/api/index.html#slot-scope) feature, like this:
18+
19+
``` html
20+
<infinite-loading>
21+
<div slot="error" slot-scope="{ trigger }">
22+
Error message, click <a href="javascript:;" @click="trigger">here</a> to retry
23+
</div>
24+
</infinite-loading>
25+
```
26+
27+
## Via Plugin API
28+
29+
In order to maintain consistent behavior for all load message when we building large application, this plugin support configure all slot using the plugin API, we just need to pass a string or Vue component for it, click [here](./configure-plugin-opts.md#slots) to read more about it.
30+
31+
The `error` slot is still the special one in this way, same as the `slot` special attribute way, if you want to impletement a retry button for users in your own error component, you can use the [`vm.$attrs`](https://cn.vuejs.org/v2/api/#vm-attrs) property, like this:
32+
33+
``` html
34+
<!-- your own error component -->
35+
<div>
36+
Error message, click
37+
<a href="javascript:;" @click="$attrs.trigger">here</a>
38+
to retry
39+
</div>
40+
```
41+
42+
If you want to keep variable clear, you also can define a function property named `trigger`, and bind it on your retry button:
43+
44+
``` js
45+
// your own error component
46+
export default {
47+
/* ... */
48+
props: {
49+
trigger: Function,
50+
},
51+
/* ... */
52+
};
53+
```

docs/zh/api/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ sidebar: auto
66

77
## 属性
88

9-
所有属性都可以通过插件 API 改写全局默认值。
9+
大多数属性都可以通过插件 API 改写全局默认值。
10+
11+
- 参考:[配置插件选项 - 属性/设置](../guide/configure-plugin-opts.md#属性-设置)
1012

1113
### distance
1214

@@ -23,7 +25,7 @@ sidebar: auto
2325
- 有效值:`default` | `spiral` | `circles` | `bubbles` | `waveDots`
2426
- 详细:
2527

26-
此选项用于设置加载动画,你可以从内置选项中选择一个你喜欢的,你也可以通过名为 `spinner`[具名插槽](https://vuejs.org/v2/guide/components.html#Named-Slots)来进行自定义。
28+
此选项用于设置加载动画,你可以从内置选项中选择一个你喜欢的,你也可以通过名为 `spinner`[具名插槽](#spinner-2)来进行自定义。
2729

2830
### direction
2931

@@ -56,6 +58,10 @@ sidebar: auto
5658

5759
插槽的内容可以通过 `Vue.js` 官方提供的 [`slot` 特殊属性](https://vuejs.org/v2/api/index.html#slot)进行设置,也可以通过插件 API 进行全局设置。
5860

61+
- 参考:
62+
- [配置加载提示](../guide/configure-load-msg.md)
63+
- [配置插件选项 - 插槽](../guide/configure-plugin-opts.md#插槽)
64+
5965
### no-results
6066

6167
- 默认值:`No results :(`

docs/zh/guide/configure-load-msg.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# 配置加载提示
2+
3+
此组件提供了四种不同的插槽用来显示不同的加载提示:`spinner``no-more``no-results``error`,你可以通过[这里](../api/#插槽)了解更多。
4+
5+
## 通过 `slot` 特殊属性
6+
7+
我们可以通过 [`slot` 特殊属性](https://vuejs.org/v2/api/index.html#slot)来配置它们:
8+
9+
``` html
10+
<infinite-loading>
11+
<div slot="spinner">Loading...</div>
12+
<div slot="no-more">No more message</div>
13+
<div slot="no-results">No results message</div>
14+
</infinite-loading>
15+
```
16+
17+
与其他插槽不同的是,`error` 插槽的默认值除了会提供文字信息之外,还会提供一个重试按钮供用户重新尝试加载;在自定义 `error` 插槽时,如果你也希望提供一个重试按钮给用户,可以使用 [`slot-scope`](https://vuejs.org/v2/api/index.html#slot-scope) 功能实现,就像下面这样:
18+
19+
``` html
20+
<infinite-loading>
21+
<div slot="error" slot-scope="{ trigger }">
22+
Error message, click <a href="javascript:;" @click="trigger">here</a> to retry
23+
</div>
24+
</infinite-loading>
25+
```
26+
27+
## 通过插件 API
28+
29+
在我们构建大型应用时,为了保证所有加载提示的行为一致,此插件支持通过插件 API 统一配置所有的插槽内容,我们只需要传递一个字符串或者 Vue 组件给它就可以了,点击[这里](./configure-plugin-opts.md#插槽)了解更多。
30+
31+
在这里 `error` 插槽仍然是最特殊的哪一个,和使用 `slot` 特殊属性一样,如果你希望提供一个重试按钮给用户,你可以使用 [`vm.$attrs`](https://cn.vuejs.org/v2/api/#vm-attrs) 属性,就像这样:
32+
33+
``` html
34+
<!-- your own error component -->
35+
<div>
36+
Error message, click
37+
<a href="javascript:;" @click="$attrs.trigger">here</a>
38+
to retry
39+
</div>
40+
```
41+
42+
如果你想保持变量名的整洁,你也可以定义一个叫做 `trigger` 的函数属性,并且把它绑定到重试按钮上即可:
43+
44+
``` js
45+
// your own error component
46+
export default {
47+
/* ... */
48+
props: {
49+
trigger: Function,
50+
},
51+
/* ... */
52+
};
53+
```

0 commit comments

Comments
 (0)