[Doc] Popup: add get-container demo (#3522)
This commit is contained in:
+49
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user