js方法
<script src="//unpkg.com/element-ui@1.4.1/lib/index.js"></script>
<div id="app" ref = 'find'>
<el-upload action="https://jsonplaceholder.typicode.com/posts/" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-change = "handleChange">
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog v-model="dialogVisible" size="tiny">

</el-dialog>
</div>
var Main = {
data() {
return {
dialogImageUrl: '',
dialogVisible: false
};
},
methods: {
handleChange () {
this.$refs.find.querySelector(".el-upload--picture-card").style.background = 'red'
},
handleRemove(file, fileList) {
this.$refs.find.querySelector(".el-upload--picture-card").style.background = 'green'
console.log(file, fileList);
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

另一种思维:
也可以在外层包个class,然后设置class宽度
超出部分隐藏overflow:hidden


这里其实应给el -form-item单独设立class也可实现这个效果
:on-change 可以改为 :on-sucess 当上传成功后再进行操作
网友评论