1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <!DOCTYPE html> <html>
<head> <meta charset="utf-8"> <title>文件上传Demo</title> </head>
<body> <div id="app"> <el-upload class="upload-demo" drag action="http://localhost:8888/upload" :data="uploadData" :before-upload="setFileName" style="position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);"> <i class="el-icon-upload"></i> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__tip" slot="tip">文件不能超过 50 MB</div> </el-upload> </div> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> <script src="https://unpkg.com/element-ui/lib/index.js"></script> <script> new Vue({ el: "#app", data: { uploadData: { fileName: new Date().getTime() } }, methods: { setFileName(file, fileList) { this.fileName = file.name } } }) </script>
</body>
</html>
|