🌐 AI搜索 & 代理 主页
Skip to content

Commit 906ddf5

Browse files
authored
Update README.md
1 parent 442d888 commit 906ddf5

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/directives/toggle/README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ details and caveats.
1616

1717
## Directive syntax and usage
1818

19-
The directive is applied to the element or component that triggers the visibility of hte target. The
19+
The directive is applied to the element or component that triggers the visibility of the target. The
2020
target component can be specified (via its ID) as either a directive modifier(s), the directive
2121
argument, or as a string/array passed to as the directive value:
2222

@@ -34,7 +34,7 @@ argument, or as a string/array passed to as the directive value:
3434

3535
Modifiers, argument, and the value can be used at the same time when targeting multiple components.
3636

37-
### Example usage
37+
**Example usage:**
3838

3939
```html
4040
<template>
@@ -62,6 +62,44 @@ Modifiers, argument, and the value can be used at the same time when targeting m
6262
<!-- v-b-toggle-directive.vue -->
6363
```
6464

65+
## Usage on links
66+
67+
<span class="badge badge-info small">2.15.0+</span>
68+
69+
If placing the directive on a link (or a component that renders a link), the target ID can
70+
alternatively be specified via the `href` attribute.
71+
72+
Note that the browser URL will change and the page may scroll the target into view. To prevent the
73+
URL from changing and the page from scrolling, add `@click.prevent` to the link.
74+
75+
**Example usage:**
76+
77+
```html
78+
<template>
79+
<div>
80+
<div class="mb-3">
81+
<a v-b-toggle href="#example-collapse" @click.prevent>Toggle Collapse</a>
82+
<b-button v-b-toggle href="#example-sidebar" @click.prevent>Toggle Sidebar</b-button>
83+
</div>
84+
85+
<b-collapse id="example-collapse">
86+
<b-card title="Collapsible card">
87+
Hello world!
88+
</b-card>
89+
</b-collapse>
90+
91+
<b-sidebar id="example-sidebar" title="Sidebar" shadow>
92+
<div class="px-3 py-2">
93+
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis
94+
in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
95+
</div>
96+
</b-sidebar>
97+
</div>
98+
</template>
99+
100+
<!-- v-b-toggle-links.vue -->
101+
```
102+
65103
## Hiding and showing content in the toggle trigger element
66104

67105
When using the `v-b-toggle` directive, the class `collapsed` will automatically be placed on the

0 commit comments

Comments
 (0)