2020-01-02 23:21:10 +08:00
|
|
|
|
# 折叠侧边栏
|
|
|
|
|
使用 `collapsed` 属性控制侧边栏状态。
|
|
|
|
|
|
|
|
|
|
侧边栏有两种 `collapse-mode`:`width`、`transform`。`width` 会改变侧边栏的宽度,而 `transform` 只是将侧边栏移除布局。
|
|
|
|
|
|
|
|
|
|
使用 `collapsed-width` 和 `width` 设置侧边栏的宽度。
|
|
|
|
|
```html
|
|
|
|
|
<n-switch v-model="collapsed" />
|
|
|
|
|
<n-layout style="height: 240px;">
|
|
|
|
|
<n-layout-header style="height: 64px;">
|
2020-02-03 20:13:14 +08:00
|
|
|
|
酷的页头
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-header>
|
|
|
|
|
<n-layout>
|
|
|
|
|
<n-layout-sider
|
|
|
|
|
collapse-mode="width"
|
|
|
|
|
:collapsed-width="120"
|
|
|
|
|
:width="240"
|
|
|
|
|
:collapsed="collapsed"
|
|
|
|
|
show-toggle-button
|
|
|
|
|
@collapse="collapsed = true"
|
|
|
|
|
@expand="collapsed = false"
|
|
|
|
|
>
|
2020-02-03 20:13:14 +08:00
|
|
|
|
<p>边栏 边栏 边栏 边栏 边栏</p>
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-sider>
|
|
|
|
|
<n-layout>
|
|
|
|
|
<n-layout-content>
|
2020-02-03 20:13:14 +08:00
|
|
|
|
<span>内容</span>
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-content>
|
|
|
|
|
<n-layout-footer>
|
2020-02-03 20:13:14 +08:00
|
|
|
|
<n-h1>页脚</n-h1>
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-footer>
|
|
|
|
|
</n-layout>
|
|
|
|
|
</n-layout>
|
|
|
|
|
</n-layout>
|
|
|
|
|
<n-layout style="height: 240px;">
|
|
|
|
|
<n-layout-header mode="absolute" style="height: 64px;">
|
2020-02-03 20:13:14 +08:00
|
|
|
|
酷的页头
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-header>
|
|
|
|
|
<n-layout mode="absolute" style="top: 64px;">
|
|
|
|
|
<n-layout-sider
|
|
|
|
|
mode="absolute"
|
|
|
|
|
collapse-mode="transform"
|
|
|
|
|
:collapsed-width="120"
|
|
|
|
|
:width="240"
|
|
|
|
|
:collapsed="collapsed"
|
|
|
|
|
show-toggle-button
|
|
|
|
|
@collapse="collapsed = true"
|
|
|
|
|
@expand="collapsed = false"
|
|
|
|
|
>
|
2020-02-03 20:13:14 +08:00
|
|
|
|
<n-h1>边栏</n-h1>
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout-sider>
|
|
|
|
|
<n-layout
|
|
|
|
|
mode="absolute"
|
|
|
|
|
>
|
2020-02-03 20:13:14 +08:00
|
|
|
|
<span>内容</span>
|
2020-01-02 23:21:10 +08:00
|
|
|
|
</n-layout>
|
|
|
|
|
</n-layout>
|
|
|
|
|
</n-layout>
|
|
|
|
|
```
|
|
|
|
|
```js
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
collapsed: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|