Skip to content

Commit a0a48d7

Browse files
committed
docs: improve
1 parent 9b87e5b commit a0a48d7

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

docs/reference/components.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,36 @@ interface AutoLinkConfig {
4747
}
4848
```
4949

50+
- Usage:
51+
5052
```md
5153
<AutoLink :config="autoLinkConfig" />
54+
55+
<AutoLink :config="autoLinkConfig">
56+
default slot
57+
</AutoLink>
58+
59+
<AutoLink :config="autoLinkConfig">
60+
<template #before>before slot</template>
61+
<template #after>after slot</template>
62+
</AutoLink>
63+
64+
<AutoLink :config="autoLinkConfig">
65+
<template v-slot="config">{{ config.text }}</template>
66+
</AutoLink>
67+
68+
<AutoLink :config="autoLinkConfig">
69+
<template #before="config">{{ config.text }}</template>
70+
</AutoLink>
5271
```
5372

5473
- Details:
5574

56-
This component will automatically render a `<RouteLink>` or `<a>` bases on your configuration.
75+
This component will automatically render internal link as `<RouteLink>`, and render external link as `<a>`. It will also add necessary attributes correspondingly.
5776

58-
It's recommended to use this component instead of the `<RouteLink>` component if the link can be both internal and external.
77+
You can make use of the `before` and `after` slots to render content before and after the text. Also, you can use the `default` slot to render the text (default text is `config.text`).
5978

60-
It has a default slot to render the content of the link (default is `config.text`), and you can also add slots named `before` and `after` to render content before and after the text.
79+
This component is mainly for developing themes. Users won't need it in most cases. For theme authors, it's recommended to use this component to render links that could be either internal or external.
6180

6281
## ClientOnly
6382

@@ -132,4 +151,4 @@ interface AutoLinkConfig {
132151

133152
If the `active` prop is set to `true`, the link will have an extra `activeClass`. Notice that the active status won't be updated automatically when the route changes.
134153

135-
This component is mainly for developing themes. You won't need it in most cases. For theme authors, it's recommended to use this component instead of the `<RouterLink>` component from `vue-router`.
154+
This component is mainly for developing themes. Users won't need it in most cases. For theme authors, it's recommended to use this component to render internal links instead of the `<RouterLink>` component from `vue-router`.

docs/zh/reference/components.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,36 @@ interface AutoLinkConfig {
4949
}
5050
```
5151

52+
- 使用:
53+
5254
```md
5355
<AutoLink :config="autoLinkConfig" />
56+
57+
<AutoLink :config="autoLinkConfig">
58+
default 插槽
59+
</AutoLink>
60+
61+
<AutoLink :config="autoLinkConfig">
62+
<template #before>before 插槽</template>
63+
<template #after>after 插槽</template>
64+
</AutoLink>
65+
66+
<AutoLink :config="autoLinkConfig">
67+
<template v-slot="config">{{ config.text }}</template>
68+
</AutoLink>
69+
70+
<AutoLink :config="autoLinkConfig">
71+
<template #before="config">{{ config.text }}</template>
72+
</AutoLink>
5473
```
5574

5675
- 详情:
5776

58-
该组件将根据您的配置自动渲染一个 `<RouteLink>` `<a>`
77+
该组件将会自动将内部链接渲染为 `<RouteLink>` ,将外部链接渲染为 `<a>` ,并添加必要的属性
5978

60-
如果链接既可以是内部链接也可以是外部链接,建议使用这个组件而不是 `<RouteLink>` 组件
79+
你可以通过 `before``after` 插槽,在文本之前和之后渲染内容。也可以通过 `default` 插槽,直接渲染文本(默认文本是 `config.text`
6180

62-
它有一个默认插槽用于渲染链接的内容(默认为 `config.text`),您还可以添加名为 `before``after` 的插槽,在文本之前和之后渲染内容
81+
该组件主要是为了开发主题时使用,普通用户在绝大多数情况下并不会用到它。对于主题作者来说,我们建议你在不确定链接是内部链接还是外部链接时,尽量使用这个组件
6382

6483
## ClientOnly
6584

@@ -134,4 +153,4 @@ interface AutoLinkConfig {
134153

135154
如果 `active` Prop 被设置为 `true` ,那么这个链接会被额外添加一个 `activeClass` 类名。需要注意的是,这里的 active 状态并不会根据当前路由自动更新。
136155

137-
该组件主要是为了开发主题时使用。在绝大多数情况下你不会用到它。对于主题作者来说,我们建议你尽可能使用这个组件,而不是使用 `vue-router``<RouterLink>` 组件。
156+
该组件主要是为了开发主题时使用,普通用户在绝大多数情况下并不会用到它。对于主题作者来说,我们建议你在渲染内部链接时尽量使用这个组件,而不是使用 `vue-router``<RouterLink>` 组件。

0 commit comments

Comments
 (0)