[Doc] Popup: add get-container demo (#3522)

This commit is contained in:
neverland
2019-06-15 16:25:51 +08:00
committed by GitHub
parent 1a91bc07cd
commit 493639a4a6
4 changed files with 209 additions and 135 deletions
+49 -5
View File
@@ -12,9 +12,11 @@ Vue.use(Popup);
### Basic Usage
Popup is located in the middle of the screen by default
```html
<van-botton type="primary" @click="showPopup">
Show Popup
</van-button>
<van-popup v-model="show">Content</van-popup>
```
@@ -24,6 +26,12 @@ export default {
return {
show: false
}
},
methods: {
showPopup() {
this.show = true;
}
}
};
```
@@ -33,9 +41,45 @@ export default {
Use `position` prop to set popup display position
```html
<van-popup v-model="show" position="top" :overlay="false">
Content
</van-popup>
<van-popup
v-model="show"
position="top"
:style="{ height: '20%' }"
/>
```
### Get Container
Use `get-container` prop to specify mount location
```html
<!-- mount to body -->
<van-popup
v-model="show"
get-container="body"
/>
<!-- mount to #app -->
<van-popup
v-model="show"
get-container="#app"
/>
<!-- Specify the mount location by function -->
<van-popup
v-model="show"
:get-container="getContainer"
/>
```
```js
export default {
methods: {
getContainer() {
return document.querySelector('.my-container');
}
}
}
```
## API