最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue對話框組件使用方法詳解

 更新時間:2022年03月03日 09:23:45   作者:theMuseCatcher  
這篇文章主要為大家詳細介紹了Vue對話框組件的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue對話框組件的使用,供大家參考,具體內容如下

效果如下圖所示:(整體樣式模仿ant-design-vue Modal樣式,同時陰影覆蓋瀏覽器窗口)

①創(chuàng)建組件Dialog.vue:

<template>
? <div class="m-dialog-mask">
? ? <div class="m-modal">
? ? ? <div class="m-modal-content">
? ? ? ? <div @click="onClose" class="u-close">&#10006;</div>
? ? ? ? <div class="m-modal-header">
? ? ? ? ? <div class="u-head">{{ title }}</div>
? ? ? ? </div>
? ? ? ? <div class="m-modal-body">
? ? ? ? ? <p>{{ content }}</p>
? ? ? ? </div>
? ? ? ? <div class="m-modal-footer" v-show="footer">
? ? ? ? ? <button class="u-cancel" @click="onCancel">{{ cancelText }}</button>
? ? ? ? ? <button class="u-confirm" @click="onConfirm">{{ okText }}</button>
? ? ? ? </div>
? ? ? </div>
? ? </div>
? </div>
</template>
<script>
export default {
? name: 'Dialog',
? props: {
? ? title: { // 標題
? ? ? type: String,
? ? ? default: '提示'
? ? },
? ? content: { // 內容
? ? ? type: String,
? ? ? default: ''
? ? },
? ? cancelText: { // 取消按鈕文字
? ? ? type: String,
? ? ? default: '取消'
? ? },
? ? okText: { // 確認按鈕文字
? ? ? type: String,
? ? ? default: '確定'
? ? },
? ? footer: { // 是否顯示底部按鈕,默認顯示
? ? ? type: Boolean,
? ? ? default: true
? ? }
? },
? methods: {
? ? onClose () {
? ? ? this.$emit('close')
? ? },
? ? onCancel () {
? ? ? this.$emit('cancel')
? ? },
? ? onConfirm () {
? ? ? this.$emit('ok')
? ? }
? }
}
</script>
<style lang="less" scoped>
.m-dialog-mask {
? position: fixed;
? top: 0;
? right: 0;
? bottom: 0;
? left: 0;
? width: 100%;
? height: 100%;
? z-index: 1000000;
? background: rgba(0,0,0,0.45);
? .m-modal {
? ? width: 720px;
? ? position: relative;
? ? top: calc(50% - 240px);
? ? margin: 0 auto;
? ? .m-modal-content {
? ? ? position: relative;
? ? ? background: #fff;
? ? ? border-radius: 4px;
? ? ? box-shadow: 0 4px 12px rgba(0,0,0,.1);
? ? ? .u-close {
? ? ? ? position: absolute;
? ? ? ? top: 16px;
? ? ? ? right: 24px;
? ? ? ? color: rgba(0,0,0,.45);
? ? ? ? font-size: 18px;
? ? ? ? line-height: 22px;
? ? ? ? cursor: pointer;
? ? ? ? transition: color .3s;
? ? ? ? &:hover {
? ? ? ? ? color: rgba(0,0,0,.75);
? ? ? ? }
? ? ? }
? ? ? .m-modal-header {
? ? ? ? height: 22px;
? ? ? ? padding: 16px 24px;
? ? ? ? color: rgba(0,0,0,.65);
? ? ? ? border-radius: 4px 4px 0 0;
? ? ? ? border-bottom: 1px solid #e8e8e8;
? ? ? ? .u-head {
? ? ? ? ? margin: 0;
? ? ? ? ? color: rgba(0,0,0,.85);
? ? ? ? ? font-weight: 500;
? ? ? ? ? font-size: 16px;
? ? ? ? ? line-height: 22px;
? ? ? ? ? word-wrap: break-word;
? ? ? ? }
? ? ? }
? ? ? .m-modal-body {
? ? ? ? height: 324px;
? ? ? ? padding: 24px;
? ? ? ? font-size: 16px;
? ? ? ? line-height: 1.5;
? ? ? ? word-wrap: break-word;
? ? ? }
? ? ? .m-modal-footer {
? ? ? ? padding: 10px 16px;
? ? ? ? text-align: right;
? ? ? ? border-top: 1px solid #e8e8e8;
? ? ? ? .u-cancel {
? ? ? ? ? height: 32px;
? ? ? ? ? line-height: 32px;
? ? ? ? ? padding: 0 15px;
? ? ? ? ? font-size: 16px;
? ? ? ? ? border-radius: 4px;
? ? ? ? ? color: rgba(0,0,0,.65);
? ? ? ? ? background: #fff;
? ? ? ? ? border: 1px solid #d9d9d9;
? ? ? ? ? cursor: pointer;
? ? ? ? ? transition: all .3s cubic-bezier(.645,.045,.355,1);
? ? ? ? ? &:hover {
? ? ? ? ? ? color: #40a9ff;
? ? ? ? ? ? border-color: #40a9ff;
? ? ? ? ? }
? ? ? ? }
? ? ? ? .u-confirm {
? ? ? ? ? margin-left: 8px;
? ? ? ? ? height: 32px;
? ? ? ? ? line-height: 32px;
? ? ? ? ? padding: 0 15px;
? ? ? ? ? font-size: 16px;
? ? ? ? ? border-radius: 4px;
? ? ? ? ? background: #1890ff;
? ? ? ? ? border: 1px solid #1890ff;
? ? ? ? ? color: #fff;
? ? ? ? ? transition: all .3s cubic-bezier(.645,.045,.355,1);
? ? ? ? ? cursor: pointer;
? ? ? ? ? &:hover {
? ? ? ? ? ? color: #fff;
? ? ? ? ? ? background: #40a9ff;
? ? ? ? ? ? border-color: #40a9ff;
? ? ? ? ? }
? ? ? ? }
? ? ? }
? ? }
? }
}
</style>

②使用Dialog組件彈出對話框:

<Dialog
? ? ? title="Title"
? ? ? :content="content"
? ? ? :footer="true"
? ? ? cancelText="取消"
? ? ? okText="確認"
? ? ? @close="onClose"
? ? ? @cancel="onCancel"
? ? ? @ok="onConfirm"
? ? ? v-show="showDialog"
? ? ? />
?
import Dialog from '@/components/Dialog'
components: {
? ? Dialog
},
data () {
? ? return {
? ? ? ? showDialog: false,
?? ? content: '',
? ? }
},
methods: {
? ? onDialog (content) { // 調用Dialog彈出對話框
? ? ? this.content = 'Content of the modal ...'
? ? ? this.showDialog = true
? ? },
? ? onClose () { // 關閉dialog
? ? ? this.showDialog = false
? ? },
? ? onCancel () { // “取消”按鈕回調
? ? ? this.showDialog = false
? ? },
? ? onConfirm () { // “確定”按鈕回調
? ? ? this.showDialog = false
? ? }
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

江门市| 青州市| 巴南区| 绵竹市| 长岛县| 晋州市| 安乡县| 集安市| 台前县| 香河县| 宾川县| 洞头县| 丹阳市| 张掖市| 长岭县| 临高县| 兴城市| 柳江县| 嘉义市| 株洲市| 青神县| 兰溪市| 灵宝市| 岐山县| 闸北区| 嵊州市| 烟台市| 东乌珠穆沁旗| 穆棱市| 防城港市| 蓝田县| 拉萨市| 亚东县| 南和县| 胶南市| 新丰县| 柳江县| 安义县| 民权县| 禄劝| 电白县|