Modal support global setting

This commit is contained in:
梁灏 2018-06-28 14:58:38 +08:00
parent 737894dee2
commit e44ba4d4ad
4 changed files with 21 additions and 28 deletions

View file

@ -12,7 +12,7 @@ import locale from '../src/locale/lang/zh-CN';
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.use(iView, { Vue.use(iView, {
locale, locale,
transfer: true, transfer: false,
size: 'small' size: 'small'
}); });

View file

@ -1,39 +1,30 @@
<template> <template>
<div> <div>
<p> <Button type="primary" @click="modal1 = true">Display dialog box</Button>
Name: {{ value }} <Modal
</p> v-model="modal1"
<p> title="Common Modal dialog box title"
<Button @click="handleRender">Custom content</Button> @on-ok="ok"
</p> @on-cancel="cancel">
<p>Content of dialog</p>
<p>Content of dialog</p>
<p>Content of dialog</p>
</Modal>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
value: '' modal1: false
} }
}, },
methods: { methods: {
handleRender () { ok () {
this.$Modal.confirm({ this.$Message.info('Clicked ok');
title: '真不错呀', },
render: (h) => { cancel () {
return h('Input', { this.$Message.info('Clicked cancel');
props: {
value: this.value,
autofocus: true,
placeholder: 'Please enter your name...'
},
on: {
input: (val) => {
this.value = val;
}
}
})
}
})
} }
} }
} }

View file

@ -99,7 +99,9 @@
}, },
transfer: { transfer: {
type: Boolean, type: Boolean,
default: true default () {
return this.$IVIEW.transfer === '' ? true : this.$IVIEW.transfer;
}
}, },
fullscreen: { fullscreen: {
type: Boolean, type: Boolean,

View file

@ -166,7 +166,7 @@ const install = function(Vue, opts = {}) {
Vue.prototype.$IVIEW = { Vue.prototype.$IVIEW = {
size: opts.size || '', size: opts.size || '',
transfer: opts.transfer || '' transfer: 'transfer' in opts ? opts.transfer : ''
}; };
Vue.prototype.$Loading = LoadingBar; Vue.prototype.$Loading = LoadingBar;