Commit abb2cae6dae0b31b2dee64f6d36aa58facd5d81b

Authored by Aresn
Committed by GitHub
2 parents 6af235b1 34324f28

Merge pull request #2568 from lison16/modal

add closable props for $Modal https://github.com/iview/iview/issues/2362
examples/routers/modal.vue
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 <i-option v-for="item in options" :value="item.value" :key="item.value">{{ item.label }}</i-option> 18 <i-option v-for="item in options" :value="item.value" :key="item.value">{{ item.label }}</i-option>
19 </i-select> 19 </i-select>
20 </Modal> 20 </Modal>
  21 + <Button @click="showModelFunc">弹出</Button>
21 </div> 22 </div>
22 </template> 23 </template>
23 <script> 24 <script>
@@ -123,6 +124,13 @@ @@ -123,6 +124,13 @@
123 item.loading = false; 124 item.loading = false;
124 callback(); 125 callback();
125 }, 1000); 126 }, 1000);
  127 + },
  128 + showModelFunc () {
  129 + this.$Modal.success({
  130 + title: 'haha',
  131 + content: 'lsisdfsdfsdfs',
  132 + closable: false
  133 + });
126 } 134 }
127 } 135 }
128 } 136 }
src/components/modal/confirm.js
@@ -22,7 +22,8 @@ Modal.newInstance = properties =&gt; { @@ -22,7 +22,8 @@ Modal.newInstance = properties =&gt; {
22 showCancel: false, 22 showCancel: false,
23 loading: false, 23 loading: false,
24 buttonLoading: false, 24 buttonLoading: false,
25 - scrollable: false 25 + scrollable: false,
  26 + closable: true
26 }), 27 }),
27 render (h) { 28 render (h) {
28 let footerVNodes = []; 29 let footerVNodes = [];
@@ -80,7 +81,8 @@ Modal.newInstance = properties =&gt; { @@ -80,7 +81,8 @@ Modal.newInstance = properties =&gt; {
80 return h(Modal, { 81 return h(Modal, {
81 props: Object.assign({}, _props, { 82 props: Object.assign({}, _props, {
82 width: this.width, 83 width: this.width,
83 - scrollable: this.scrollable 84 + scrollable: this.scrollable,
  85 + closable: this.closable
84 }), 86 }),
85 domProps: { 87 domProps: {
86 value: this.visible 88 value: this.visible
@@ -210,6 +212,10 @@ Modal.newInstance = properties =&gt; { @@ -210,6 +212,10 @@ Modal.newInstance = properties =&gt; {
210 modal.$parent.width = props.width; 212 modal.$parent.width = props.width;
211 } 213 }
212 214
  215 + if ('closable' in props) {
  216 + modal.$parent.closable = props.closable;
  217 + }
  218 +
213 if ('title' in props) { 219 if ('title' in props) {
214 modal.$parent.title = props.title; 220 modal.$parent.title = props.title;
215 } 221 }