Commit e44ba4d4ad96ce8e3d3decb3a5afc2cf19931405

Authored by 梁灏
1 parent 737894de

Modal support global setting

@@ -12,7 +12,7 @@ import locale from '../src/locale/lang/zh-CN'; @@ -12,7 +12,7 @@ import locale from '../src/locale/lang/zh-CN';
12 Vue.use(VueRouter); 12 Vue.use(VueRouter);
13 Vue.use(iView, { 13 Vue.use(iView, {
14 locale, 14 locale,
15 - transfer: true, 15 + transfer: false,
16 size: 'small' 16 size: 'small'
17 }); 17 });
18 18
examples/routers/modal.vue
1 <template> 1 <template>
2 <div> 2 <div>
3 - <p>  
4 - Name: {{ value }}  
5 - </p>  
6 - <p>  
7 - <Button @click="handleRender">Custom content</Button>  
8 - </p> 3 + <Button type="primary" @click="modal1 = true">Display dialog box</Button>
  4 + <Modal
  5 + v-model="modal1"
  6 + title="Common Modal dialog box title"
  7 + @on-ok="ok"
  8 + @on-cancel="cancel">
  9 + <p>Content of dialog</p>
  10 + <p>Content of dialog</p>
  11 + <p>Content of dialog</p>
  12 + </Modal>
9 </div> 13 </div>
10 </template> 14 </template>
11 <script> 15 <script>
12 export default { 16 export default {
13 data () { 17 data () {
14 return { 18 return {
15 - value: '' 19 + modal1: false
16 } 20 }
17 }, 21 },
18 methods: { 22 methods: {
19 - handleRender () {  
20 - this.$Modal.confirm({  
21 - title: '真不错呀',  
22 - render: (h) => {  
23 - return h('Input', {  
24 - props: {  
25 - value: this.value,  
26 - autofocus: true,  
27 - placeholder: 'Please enter your name...'  
28 - },  
29 - on: {  
30 - input: (val) => {  
31 - this.value = val;  
32 - }  
33 - }  
34 - })  
35 - }  
36 - }) 23 + ok () {
  24 + this.$Message.info('Clicked ok');
  25 + },
  26 + cancel () {
  27 + this.$Message.info('Clicked cancel');
37 } 28 }
38 } 29 }
39 } 30 }
src/components/modal/modal.vue
@@ -99,7 +99,9 @@ @@ -99,7 +99,9 @@
99 }, 99 },
100 transfer: { 100 transfer: {
101 type: Boolean, 101 type: Boolean,
102 - default: true 102 + default () {
  103 + return this.$IVIEW.transfer === '' ? true : this.$IVIEW.transfer;
  104 + }
103 }, 105 },
104 fullscreen: { 106 fullscreen: {
105 type: Boolean, 107 type: Boolean,
@@ -166,7 +166,7 @@ const install = function(Vue, opts = {}) { @@ -166,7 +166,7 @@ const install = function(Vue, opts = {}) {
166 166
167 Vue.prototype.$IVIEW = { 167 Vue.prototype.$IVIEW = {
168 size: opts.size || '', 168 size: opts.size || '',
169 - transfer: opts.transfer || '' 169 + transfer: 'transfer' in opts ? opts.transfer : ''
170 }; 170 };
171 171
172 Vue.prototype.$Loading = LoadingBar; 172 Vue.prototype.$Loading = LoadingBar;