mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-08 23:44:44 +00:00
51 lines
1.2 KiB
Vue
51 lines
1.2 KiB
Vue
<template>
|
|
<md-dialog class="md-dialog-alert" ref="dialog" @close="fireCloseEvent()">
|
|
<md-dialog-title v-if="mdTitle">{{ mdTitle }}</md-dialog-title>
|
|
|
|
<md-dialog-content v-if="mdContentHtml" v-html="mdContentHtml"></md-dialog-content>
|
|
<md-dialog-content v-else>{{ mdContent }}</md-dialog-content>
|
|
|
|
<md-dialog-actions>
|
|
<md-button class="md-primary" @click="close()">{{ mdOkText }}</md-button>
|
|
</md-dialog-actions>
|
|
</md-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
mdTitle: String,
|
|
mdContent: String,
|
|
mdContentHtml: String,
|
|
mdOkText: {
|
|
type: String,
|
|
default: 'Ok'
|
|
}
|
|
},
|
|
data: () => ({
|
|
debounce: false
|
|
}),
|
|
methods: {
|
|
fireCloseEvent() {
|
|
if (!this.debounce) {
|
|
this.$emit('close');
|
|
}
|
|
},
|
|
open() {
|
|
this.$emit('open');
|
|
this.debounce = false;
|
|
this.$refs.dialog.open();
|
|
},
|
|
close() {
|
|
this.fireCloseEvent();
|
|
this.debounce = true;
|
|
this.$refs.dialog.close();
|
|
}
|
|
},
|
|
mounted() {
|
|
if (!this.mdContent && !this.mdContentHtml) {
|
|
throw new Error('Missing md-content or md-content-html attributes');
|
|
}
|
|
}
|
|
};
|
|
</script>
|