naive-ui/demo/documentation/components/drawer/zhCN/target.md

47 lines
1.0 KiB
Markdown
Raw Normal View History

2020-03-15 22:58:26 +08:00
# 显示在指定区域
```html
<n-button-group>
2020-03-17 16:48:36 +08:00
<n-button @click="activate('top')"></n-button>
<n-button @click="activate('right')"></n-button>
<n-button @click="activate('bottom')"></n-button>
<n-button @click="activate('left')"></n-button>
2020-03-15 22:58:26 +08:00
</n-button-group>
2020-03-17 16:48:36 +08:00
<div
2020-03-17 18:54:21 +08:00
ref="target"
2020-03-17 16:48:36 +08:00
style="position:relative;
2020-03-20 16:04:42 +08:00
width: 100%;
height: 500px;
border: 1px solid rgba(0, 0, 0, .1);
2020-03-17 16:48:36 +08:00
margin-top: 10px;"
>
2020-03-19 13:26:06 +08:00
<p style="position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);">
显示区域
</p>
2020-03-15 22:58:26 +08:00
</div>
<n-drawer v-model="active" :width="200" :placement="placement" :target="target">
2020-03-17 16:48:36 +08:00
<n-h1>斯通纳</n-h1>
<n-p>《斯通纳》是美国作家约翰·威廉姆斯在 1965 年出版的小说。</n-p>
2020-03-15 22:58:26 +08:00
</n-drawer>
```
```js
export default {
data () {
return {
active: false,
placement: 'right'
}
},
methods: {
activate (placement) {
this.active = true
this.placement = placement
},
target () {
2020-03-17 18:54:21 +08:00
return this.$refs.target
2020-03-15 22:58:26 +08:00
}
}
}
```