彈出框,可自定義內(nèi)容。
import { Popup } from 'mint-ui';
Vue.component(Popup.name, Popup);
position 屬性指定了 popup 的位置。比如,position 為 'bottom' 時,popup 會從屏幕下方移入,并最終固定在屏幕下方。移入/移出的動效會根據(jù) position 的不同而自動改變,無需手動配置。
將 v-model 綁定到一個本地變量,通過操作這個變量即可控制 popup 的顯示與隱藏。
<mt-popup
v-model="popupVisible"
position="bottom">
...
</mt-popup>
若省略 position 屬性,則 popup 會相對于屏幕居中顯示(若不想讓其居中,可通過 CSS 對其重新定位)。此時建議將動效設(shè)置為 popup-fade,這樣在顯示/隱藏時會有淡入/淡出效果。
<mt-popup
v-model="popupVisible"
popup-transition="popup-fade">
...
</mt-popup>
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
position | popup 的位置。省略則居中顯示 |
String | 'top'
'right' 'bottom' 'left' |
|
pop-transition | 顯示/隱藏時的動效,僅在省略 position 時可配置 |
String | 'popup-fade' | |
modal | 是否創(chuàng)建一個 modal 層 | Boolean | true | |
closeOnClickModal | 是否可以通過點擊 modal 層來關(guān)閉 popup
|
Boolean | true |
name | 描述 |
---|---|
- | 彈出框的內(nèi)容 |
<html>
<head>
<meta charset="UTF-8">
<!-- 引入樣式 -->
<link rel="stylesheet" rel="external nofollow" target="_blank" >
</head>
<body>
<div id="app">
<mt-button @click.native="handleClick">按鈕</mt-button>
<mt-popup v-model="popupVisible" position="left" modal=false>
<child> </child>
</mt-popup>
</div>
</body>
<!-- 先引入 Vue -->
<script src="https://unpkg.com/vue/dist/vue.js" rel="external nofollow" ></script>
<!-- 引入組件庫 -->
<script src="https://unpkg.com/mint-ui/lib/index.js" rel="external nofollow" ></script>
<script>
new Vue({
el: '#app',
data: {
popupVisible: false
},
methods: {
handleClick: function () {
this.popupVisible = true
}
},
components: {
child: {
template: "<h1>w3cschool</h1>"
}
}
})
</script>
</html>
更多建議: