Authored by htoooth

fix

1 <template> 1 <template>
2 - <div> 2 + <div v-if="show">
3 <div class="upload-image-item" v-if="uploadList[0]"> 3 <div class="upload-image-item" v-if="uploadList[0]">
4 <template v-if="uploadList[0].status === 'finished' || uploadList[0].url"> 4 <template v-if="uploadList[0].status === 'finished' || uploadList[0].url">
5 <img :src="uploadList[0].url"> 5 <img :src="uploadList[0].url">
@@ -57,6 +57,7 @@ export default { @@ -57,6 +57,7 @@ export default {
57 return { 57 return {
58 imgUrl: '', 58 imgUrl: '',
59 visible: false, 59 visible: false,
  60 + show: true,
60 uploadList: [], 61 uploadList: [],
61 defaultList: _this.defaultFile ? [{url: _this.defaultFile}] : [] 62 defaultList: _this.defaultFile ? [{url: _this.defaultFile}] : []
62 }; 63 };
@@ -94,11 +95,25 @@ export default { @@ -94,11 +95,25 @@ export default {
94 title: '超出文件大小限制', 95 title: '超出文件大小限制',
95 desc: '文件 ' + file.name + ' 太大,不能超过 2M。' 96 desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
96 }); 97 });
  98 + },
  99 + render: function() {
  100 + this.show = false;
  101 + this.$nextTick(() => {
  102 + this.show = true;
  103 + })
97 } 104 }
98 }, 105 },
99 mounted() { 106 mounted() {
100 this.uploadList = this.$refs.upload.fileList; 107 this.uploadList = this.$refs.upload.fileList;
101 }, 108 },
  109 + watch: {
  110 + defaultFile: function(newValue) {
  111 + if (newValue) {
  112 + this.$refs.upload.fileList.push({url: this.defaultFile});
  113 + this.render();
  114 + }
  115 + }
  116 + }
102 }; 117 };
103 </script> 118 </script>
104 <style> 119 <style>