JSFiddle - React, Tailwind, and code Playground
by l xk
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>
<div id="app">
<el-upload class="upload-demo" ref="upload" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" :file-list="fileList" :auto-upload="false" :on-change="beforeAvatarUpload">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload" v-show="fileList.length > 0">上传到服务器</el-button>
</el-upload>
</div>
SCSS
@import url("//unpkg.com/[email protected]/lib/theme-chalk/index.css");
Babel + JSX
var Main = {
data() {
return {
fileList: []
};
},
methods: {
submitUpload() {
this.$refs.upload.submit();
},
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
beforeAvatarUpload(file, fileList){
console.log('fileList', fileList)
this.fileList = fileList
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')