{"id":25,"date":"2022-05-10T13:52:30","date_gmt":"2022-05-10T05:52:30","guid":{"rendered":"http:\/\/log.aileme.top\/?p=25"},"modified":"2022-07-21T18:08:38","modified_gmt":"2022-07-21T10:08:38","slug":"vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/","title":{"rendered":"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6"},"content":{"rendered":"\n<p>\u6628\u5929\u540e\u7aef\u8dd1\u8fc7\u6765\u8bf4\u963f\u91ccoss\u89c6\u9891\u4e0a\u4f20\u8981\u524d\u7aef\u81ea\u5df1\u96c6\u6210\u76f4\u4f20\uff0c\u8bdd\u4e0d\u591a\u8bf4\u76f4\u63a5\u4e0a\u4ee3\u7801<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u8fd9\u91cc\u4f7f\u7528\u7684\u662fSTSToken\u65b9\u5f0f\u4e0a\u4f20\u7684\uff0c\u83b7\u53d6STS\u7684\u65b9\u6cd5\u9700\u8981\u540e\u7aef\u53bb\u96c6\u6210\u51fa\u6765\u4e00\u4e2a\u63a5\u53e3\uff0c\u76f8\u5173\u6587\u6863\u94fe\u63a5\u5728\u4e0b\u65b9<\/p>\n\n\n\n<p>\u76f8\u5173\u6587\u6863\u70b9\u51fb\u8df3\u8f6c\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/help.aliyun.com\/document_detail\/100624.htm?spm=a2c4g.11186623.0.0.2f47778f7DCc5B#concept-xzh-nzk-2gb\" target=\"_blank\" rel=\"noreferrer noopener\">\u4f7f\u7528\u4e34\u65f6\u51ed\u8bc1\u8bbf\u95eeSTSToken\u8bbf\u95eeOSS<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/help.aliyun.com\/document_detail\/121136.htm?spm=a2c4g.11186623.0.0.6c393767AdNrS7#reference-w5t-25v-xdb\" target=\"_blank\" rel=\"noreferrer noopener\">\u5404\u8bed\u8a00\u83b7\u53d6STSToken\u7684\u65b9\u5f0fSTS SDK\u652f\u6301Java\u3001.NET\u3001Python\u3001PHP\u3001Node.js\u548cGo\u8bed\u8a00<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662finit\u65b9\u6cd5\u5185\u9700\u8981\u6362\u6210\u81ea\u5df1\u540e\u7aef\u7ed9\u7684\u63a5\u53e3\u62ff\u5230\u914d\u7f6e\u4fe1\u606f\uff0cSTStoken\u65b9\u5f0f\u4e0a\u4f20\u4f7f\u7528\u7684\u662f\u540e\u7aef\u83b7\u53d6\u7684\u4e34\u65f6accessKeyId\u8ddf\u4e34\u65f6secret\uff0c\u800c\u4e0d\u662f\u963f\u91cc\u4e91\u8d26\u6237\u56fa\u5b9a\u7684keyid<\/p>\n\n\n\n<p>\u540e\u7aef\u8fd4\u56de\u63a5\u53e3\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"408\" src=\"http:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-1024x408.png\" alt=\"\" class=\"wp-image-26\" srcset=\"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-1024x408.png 1024w, https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-300x120.png 300w, https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-768x306.png 768w, https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-1536x612.png 1536w, https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-2048x817.png 2048w, https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-670x267.png 670w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:8px;letter-spacing:-1px\"><code>&lt;template&gt;\n\t&lt;!--\u5728\u6b64\u5904\u6dfb\u52a0\u6e32\u67d3\u7684\u5185\u5bb9--&gt;\n\t&lt;div&gt;\n\t\t&lt;el-upload class=\"upload-demo\" ref=\"upload\" :on-success=\"handleSuccess\" :before-upload=\"beforeUpload\"\n\t\t\taccept=\"video\/*\" :http-request=\"handleHttpRequest\" :headers=\"uploadHeaders\" :limit=\"1\" :file-list=\"fileList\"\n\t\t\t:show-file-list=\"false\" action=\"\"&gt;\n\t\t\t&lt;el-button slot=\"trigger\" size=\"small\" type=\"primary\" icon=\"el-icon-plus\"\n\t\t\t\t:disabled=\"uploadType == 'loading' || uploadType == 'pause'\" style=\"margin-right: 10px;\"&gt;\u9009\u53d6\u6587\u4ef6\n\t\t\t&lt;\/el-button&gt;\n\t\t\t&lt;el-button size=\"small\" @click=\"pauseUpload\" type=\"warning\" icon=\"el-icon-video-pause\"\n\t\t\t\tv-if=\"uploadType == 'loading'\"&gt;\u6682\u505c\u4e0a\u4f20\n\t\t\t&lt;\/el-button&gt;\n\t\t\t&lt;el-button size=\"small\" @click=\"resumeUpload\" type=\"warning\" icon=\"el-icon-refresh\"\n\t\t\t\tv-if=\"uploadType == 'pause' || uploadType == 'error'\"&gt;\u6062\u590d\u4e0a\u4f20\n\t\t\t&lt;\/el-button&gt;\n\t\t\t&lt;el-button size=\"small\" @click=\"clearFile\" type=\"danger\" icon=\"el-icon-delete\"\n\t\t\t\tv-if=\"uploadType == 'error' || uploadType == 'success'\"&gt;\u6e05\u9664\u6587\u4ef6&lt;\/el-button&gt;\n\t\t\t&lt;div slot=\"tip\" v-if=\"file != null\" class=\"el-upload-list__item-preview\"&gt;{{file.name}}&lt;\/div&gt;\n\t\t\t&lt;div slot=\"tip\" class=\"el-upload__tip\"&gt;\u53ea\u80fd\u4e0a\u4f20\u89c6\u9891\u6587\u4ef6 \u6587\u4ef6\u5927\u5c0f\u4e0d\u8d85\u8fc710G&lt;\/div&gt;\n\t\t\t&lt;el-progress v-if=\"percent &gt; 0\" :text-inside=\"true\" :stroke-width=\"18\" :percentage=\"percent\"\n\t\t\t\t:status=\"percentType\" style=\"margin-top: 10px;\"&gt;&lt;\/el-progress&gt;\n\t\t&lt;\/el-upload&gt;\n\t&lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script type=\"text\/ecmascript-6\"&gt;\n\timport request from \"@\/service\/http\"\n\timport proxy from '@\/utils\/proxy'\n\timport qs from 'qs'\n\timport OSS from 'ali-oss'\n\t\/\/\u5c06\u6e32\u67d3\u7684\u5185\u5bb9\u5bfc\u51fa\n\texport default {\n\t\tprops: {\n\t\t\tprefix:{\n\t\t\t\ttype:String,\n\t\t\t\tdefault () {\n\t\t\t\t\treturn '';\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\tregion: 'oss-cn-beijing',\n\t\t\t\tbucket: '', \/\/\u8fd9\u91cc\u9009\u62e9OSS\u5bb9\u5668\n\t\t\t\tpercent: 0,\n\t\t\t\turl: '', \/\/\u540e\u53f0\u83b7\u53d6token\u5730\u5740\n\t\t\t\tClientObj: null,\n\t\t\t\tdataObj: {},\n\t\t\t\texpiration: '',\n\t\t\t\tfileList: &#91;],\n\t\t\t\tuploadHeaders: {\n\t\t\t\t\tauthorization: '*'\n\t\t\t\t},\n\t\t\t\tdisabled: false,\n\t\t\t\tclient: null,\n\t\t\t\tisInit: false,\n\t\t\t\tuploadType: 'wait', \/\/ success \u6210\u529f error \u5931\u8d25 loading \u4e0a\u4f20\u4e2d pause \u6682\u505c\u4e0a\u4f20 wait \u672a\u64cd\u4f5c\n\t\t\t\tpercentType: 'primary', \/\/ \u8fdb\u5ea6\u6761\u72b6\u6001\n\t\t\t\tabortCheckpoint: null, \/\/ \u65ad\u70b9\n\t\t\t\tfileSuccessUrl: &#91;] \/\/\u6700\u7ec8\u4e0a\u4f20\u7684\u5730\u5740\n\t\t\t}\n\t\t},\n\t\twatch: {\n\t\t\tfileSuccessUrl() {\n\t\t\t\tif (this.fileSuccessUrl.length &gt; 0) {\n\t\t\t\t\tif (this.fileSuccessUrl.length == 1) {\n\t\t\t\t\t\t\/\/\u62c6\u5206\u6389\u8fd4\u56de\u7684uploadid\n\t\t\t\t\t\tthis.$emit(\"input\", this.fileSuccessUrl&#91;0].substring(0, this.fileSuccessUrl&#91;0].lastIndexOf(\"?\")));\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/\/\u62c6\u5206\u6389\u8fd4\u56de\u7684uploadid\n\t\t\t\t\t\tthis.fileSuccessUrl.forEach((item,i)=&gt;{\n\t\t\t\t\t\t\tthis.fileSuccessUrl&#91;i] = this.fileSuccessUrl&#91;i].substring(0, this.fileSuccessUrl&#91;i].lastIndexOf(\"?\"));\n\t\t\t\t\t\t})\n\t\t\t\t\t\tthis.$emit(\"input\", this.fileSuccessUrl);\n\t\t\t\t\t}\n\t\t\t\t\tthis.$emit('success',this.fileSuccessUrl);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tmethods: {\n\t\t\t\/**\n\t\t\t * \u8bf7\u6c42\u63a5\u53e3\u62ff\u5230accesskeyid \u7b49\u7b49\u4e00\u4e9b\u914d\u7f6e\u4fe1\u606f \u5e76\u521d\u59cb\u5316\u963f\u91ccoss \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tasync init() { \/\/\u83b7\u53d6Token\n\t\t\t\tthis.fileList = &#91;];\n\t\t\t\tthis.file = null;\n\t\t\t\tthis.uploadType = 'wait'; \/\/ success \u6210\u529f error \u5931\u8d25 loading \u4e0a\u4f20\u4e2d pause \u6682\u505c\u4e0a\u4f20 wait \u672a\u64cd\u4f5c\n\t\t\t\tthis.percentType = 'primary'; \/\/ \u8fdb\u5ea6\u6761\u72b6\u6001\n\t\t\t\tthis.abortCheckpoint = null;\n\t\t\t\tlet param = {\n\t\t\t\t\tuserId: this.$store.state.userId\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\/\/\u83b7\u53d6sts token\u62ff\u5230\u53c2\u6570\u914d\u7f6e\n\t\t\t\tlet res = await request({\n\t\t\t\t\turl: proxy.baseURL + `\/api\/ali\/getAliStsToken`,\n\t\t\t\t\tmethod: 'post',\n\t\t\t\t\tdata: qs.stringify(param)\n\t\t\t\t})\n\t\t\t\tif (res.code == 0) {\n\t\t\t\t\tthis.dataObj = {\n\t\t\t\t\t\tbucket: 'hoohui',\n\t\t\t\t\t\tregion: 'oss-cn-beijing',\n\t\t\t\t\t\taccessKeyId: res.data.credentials.accessKeyId, \/\/\u4e34\u65f6accessid\n\t\t\t\t\t\taccessKeySecret: res.data.credentials.accessKeySecret, \/\/\u4e34\u65f6\u79d8\u94a5\n\t\t\t\t\t\tstsToken: res.data.credentials.securityToken,\n\t\t\t\t\t};\n\t\t\t\t\t\/\/\u521d\u59cb\u5316\n\t\t\t\t\tthis.client = new OSS(this.dataObj),\n\t\t\t\t\t\tthis.isInit = true; \/\/\u521d\u59cb\u5316\u5b8c\u6bd5\n\t\t\t\t\tthis.$forceUpdate();\n\t\t\t\t} else {\n\t\t\t\t\tthis.$message.error('\u521d\u59cb\u5316\u5931\u8d25')\n\t\t\t\t}\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u4e0a\u4f20\u6587\u4ef6\u524d \u6587\u4ef6\u9a8c\u8bc1\u5927\u5c0f \u5e76\u68c0\u6d4b\u662f\u5426\u521d\u59cb\u5316\u963f\u91ccoss \u5982\u672a\u521d\u59cb\u5316\u5219\u5148\u521d\u59cb\u5316 \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tasync beforeUpload(file) {\n\t\t\t\t\n\t\t\t\t\/\/\u9650\u5236\u7684\u4e0a\u9650\u4e3a10G  \n\t\t\t\tconst maxSize = 1024 * 1024 * 1024 * 10;\n\t\t\t\tif (maxSize &lt; file.size) {\n\t\t\t\t\tthis.$message.error('\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u4e0d\u80fd\u8d85\u8fc7 10G!');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!this.isInit) { \/\/\u5224\u65ad\u6709\u6ca1\u6709\u521d\u59cb\u5316\n\t\t\t\t\tawait this.init(); \/\/\u521d\u59cb\u5316\u6d41\u7a0b\n\t\t\t\t}\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u4e0a\u4f20\u5230oss \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tasync handleHttpRequest(option) { \/\/\u4e0a\u4f20OSS\n\t\t\t\ttry {\n\t\t\t\t\tlet that = this;\n\t\t\t\t\tthat.uploadType = 'loading';\n\t\t\t\t\tthat.percentType = 'warning';\n\t\t\t\t\tlet file = option.file;\n\t\t\t\t\tthat.file = file;\n\t\t\t\t\tthat.$emit(\"chooseFile\", file);\n\t\t\t\t\t\/\/\u968f\u673a\u547d\u540d\n\t\t\t\t\t\n\t\t\t\t\tconst random_name = that.random_string(6) + '_' + new Date().getTime() + '.' + file.name.split('.')\n\t\t\t\t\t\t.pop();\n\t\t\t\t\t\/\/ \u5206\u7247\u4e0a\u4f20\u6587\u4ef6\n\t\t\t\t\tawait that.client.multipartUpload(that.prefix + random_name, file, {\n\t\t\t\t\t\tprogress: async function(p, cpt, res) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\/\/ \u4e3a\u4e2d\u65ad\u70b9\u8d4b\u503c\u3002\n\t\t\t\t\t\t\tthat.abortCheckpoint = cpt;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tthat.percent = parseInt(p * 100);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(({\n\t\t\t\t\t\tres\n\t\t\t\t\t}) =&gt; {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (res.statusCode === 200) {\n\t\t\t\t\t\t\t\/\/ option.onSuccess(ret)\n\t\t\t\t\t\t\tthat.fileSuccessUrl = res.requestUrls;\n\n\t\t\t\t\t\t\tthat.uploadType = 'success';\n\t\t\t\t\t\t\tthat.percentType = 'success';\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tthat.uploadType = 'error';\n\t\t\t\t\t\t\tthat.percentType = 'error';\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}).catch(error =&gt; {\n\t\t\t\t\t\tthat.uploadType = 'error';\n\t\t\t\t\t\tthat.percentType = 'error';\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\n\t\t\t\t} catch (error) {\n\n\t\t\t\t\tthis.uploadType = 'error';\n\t\t\t\t\tthis.percentType = 'error';\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u4e0a\u4f20\u6210\u529f \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\thandleSuccess(response, file, fileList) {\n\t\t\t\tthis.uploadType = 'success';\n\t\t\t\tthis.percentType = 'success';\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u6682\u505c\u4e0a\u4f20 \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tpauseUpload() {\n\t\t\t\tthis.client.cancel();\n\t\t\t\tthis.uploadType = 'pause';\n\t\t\t\tthis.percentType = 'warning';\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u6e05\u9664\u6587\u4ef6 \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tclearFile() {\n\t\t\t\tthis.fileList = &#91;];\n\t\t\t\tthis.file = null;\n\t\t\t\tthis.uploadType = 'wait';\n\t\t\t\tthis.percentType = 'primary';\n\t\t\t\tthis.percent = 0;\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u6062\u590d\u4e0a\u4f20 \n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t *\/\n\t\t\tasync resumeUpload() {\n\t\t\t\tlet that = this;\n\t\t\t\tthat.uploadType = 'loading';\n\t\t\t\tthat.percentType = 'warning';\n\t\t\t\tlet file = that.file;\n\t\t\t\tlet abortCheckpoint = that.abortCheckpoint;\n\t\t\t\tawait that.client.multipartUpload(name, file, {\n\t\t\t\t\tcheckpoint: abortCheckpoint,\n\t\t\t\t\tprogress: (p, cpt, res) =&gt; {\n\t\t\t\t\t\t\/\/ \u4e3a\u4e86\u5b9e\u73b0\u65ad\u70b9\u4e0a\u4f20\uff0c\u60a8\u53ef\u4ee5\u5728\u4e0a\u4f20\u8fc7\u7a0b\u4e2d\u4fdd\u5b58\u65ad\u70b9\u4fe1\u606f\uff08checkpoint\uff09\u3002\u53d1\u751f\u4e0a\u4f20\u9519\u8bef\u540e\uff0c\u5c06\u5df2\u4fdd\u5b58\u7684checkpoint\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9multipartUpload\uff0c\u6b64\u65f6\u5c06\u4ece\u4e0a\u6b21\u4e0a\u4f20\u5931\u8d25\u7684\u5730\u65b9\u7ee7\u7eed\u4e0a\u4f20\u3002\n\t\t\t\t\t\t\/\/ \u4e3a\u4e2d\u65ad\u70b9\u8d4b\u503c\u3002\n\t\t\t\t\t\tthat.abortCheckpoint = cpt;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\/\/ \u83b7\u53d6\u4e0a\u4f20\u8fdb\u5ea6\u3002\n\t\t\t\t\t\t\n\t\t\t\t\t\tthat.percent = parseInt(p * 100);\n\t\t\t\t\t\t\n\t\t\t\t\t},\n\t\t\t\t}).then(({\n\t\t\t\t\tres\n\t\t\t\t}) =&gt; {\n\t\t\t\t\t\n\t\t\t\t\tif (res.statusCode === 200) {\n\n\t\t\t\t\t\tthat.fileSuccessUrl = res.requestUrls;\n\t\t\t\t\t\tthat.uploadType = 'success';\n\t\t\t\t\t\tthat.percentType = 'success';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthat.uploadType = 'error';\n\t\t\t\t\t\tthat.percentType = 'error';\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}).catch(error =&gt; {\n\t\t\t\t\tthat.uploadType = 'error';\n\t\t\t\t\tthat.percentType = 'error';\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t});;\n\t\t\t},\n\t\t\t\/**\n\t\t\t * \u8bbe\u7f6e\u8fdb\u5ea6\u6761\u72b6\u6001 \n\t\t\t * \u53d1\u73b0\u6700\u540e\u66f4\u65b0\u6570\u636e\u540e\u9875\u9762\u6ca1\u6709\u8fbe\u5230\u9884\u671f\u6548\u679c \u6ca1\u6709\u7528\u4e86\n\t\t\t * @author \u6728\u5934\u4eba\u4e0b\u58eb\n\t\t\t * @time 2022-05-09\n\t\t\t * @param {Object} type\n\t\t\t *\/\n\t\t\t\/\/ async setPercentType(type) {\n\t\t\t\/\/ \t\n\t\t\t\/\/ \tthis.$set(this, 'uploadType', type);\n\t\t\t\/\/ \t\n\t\t\t\/\/ \tswitch (type) {\n\t\t\t\/\/ \t\tcase 'wait' || 'loading':\n\t\t\t\/\/ \t\t\tthis.$set(this, 'percentType', 'primary');\n\t\t\t\/\/ \t\t\tthis.percentType = 'primary';\n\t\t\t\/\/ \t\t\tbreak;\n\t\t\t\/\/ \t\tcase 'pause':\n\t\t\t\/\/ \t\t\tthis.$set(this, 'percentType', 'warning');\n\t\t\t\/\/ \t\t\tthis.percentType = 'warning';\n\t\t\t\/\/ \t\t\tbreak;\n\t\t\t\/\/ \t\tcase 'success' || 'error':\n\t\t\t\/\/ \t\t\tif (type == 'success') {\n\t\t\t\/\/ \t\t\t\tthis.percent = 0;\n\t\t\t\/\/ \t\t\t}\n\t\t\t\/\/ \t\t\tthis.$set(this, 'percentType', type);\n\t\t\t\/\/ \t\t\tthis.percentType = type;\n\t\t\t\/\/ \t\t\tbreak;\n\t\t\t\/\/ \t\tdefault:\n\t\t\t\/\/ \t\t\tthis.uploadType = 'wait';\n\t\t\t\/\/ \t\t\tthis.percentType = 'primary';\n\t\t\t\/\/ \t\t\tbreak;\n\t\t\t\/\/ \t}\n\t\t\t\/\/ \tawait this.$forceUpdate();\n\t\t\t\/\/ },\n\t\t\tgetDate() {\n\t\t\t\tconst date = new Date(),\n\t\t\t\t\tyear = date.getFullYear(),\n\t\t\t\t\tmonth = date.getMonth() &gt; 9 ? date.getMonth() + 1 : `0${date.getMonth() + 1}`,\n\t\t\t\t\tday = date.getDate() &gt; 9 ? date.getDate() : `0${date.getDate()}`,\n\t\t\t\t\thh = date.getHours() &gt; 9 ? date.getHours() : `0${date.getHours()}`,\n\t\t\t\t\tmm = date.getMinutes() &gt; 9 ? date.getMinutes() : `0${date.getMinutes()}`;\n\t\t\t\treturn `${year}${month}${day}${hh}${mm}`;\n\t\t\t},\n\t\t\t\/\/ \u968f\u673a\u751f\u6210\u6587\u4ef6\u540d\n\t\t\trandom_string(len) {\n\t\t\t\tlen = len || 32;\n\t\t\t\tlet chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz12345678',\n\t\t\t\t\tmaxPos = chars.length,\n\t\t\t\t\tpwd = '';\n\t\t\t\tfor (let i = 0; i &lt; len; i++) {\n\t\t\t\t\tpwd += chars.charAt(Math.floor(Math.random() * maxPos));\n\t\t\t\t}\n\t\t\t\treturn pwd;\n\t\t\t}\n\n\t\t},\n\t\tcomponents: {},\n\t\tcomputed: {},\n\t\tcreated() {},\n\t\tmounted() {},\n\n\t}\n&lt;\/script&gt;\n\n&lt;style scoped&gt;\n\t\/**\u6e32\u67d3\u5185\u5bb9\u7684\u6837\u5f0f**\/\n&lt;\/style&gt;\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u65b9\u6cd5<\/p>\n\n\n\n<p>1\uff1a\u9875\u9762\u4e2d\u5f15\u5165\u7ec4\u4ef6 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import uploadFile from \"@\/components\/uploadFile\";<\/code><\/pre>\n\n\n\n<p>2\uff1a\u6ce8\u518c\u5230\u9875\u9762components\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u6ce8\u518c\u5230\u5168\u5c40\u7ec4\u4ef6\u8fd9\u91cc\u5c31\u4e0d\u4ecb\u7ecd\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>components:{\n\tuploadFile\n},<\/code><\/pre>\n\n\n\n<p>3\uff1ahtml\u90e8\u5206\u6dfb\u52a0  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;uploadFile ref=\"uploadFile\" @success=\"successFile\" @chooseFile=\"chooseFile\" v-model=\"successurl\"&gt;&lt;\/uploadFile&gt;<\/code><\/pre>\n\n\n\n<p>4\uff1a\u7ec4\u4ef6\u4f7f\u7528\u7684\u53cc\u5411\u7ed1\u5b9a\uff0c\u53ef\u4ee5\u76f4\u63a5\u7ed1\u5b9a\u4e00\u4e2a\u6570\u636e\u5c31\u53ef\u4ee5\u4e86<\/p>\n\n\n\n<p>5\uff1a\u652f\u6301\u4e24\u4e2a\u4e8b\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>methods:{\n    \/\/@chooseFile \u76d1\u542c\u9009\u62e9\u6587\u4ef6\uff0c\u4f1a\u628a\u9009\u4e2d\u7684\u6587\u4ef6\u8fd4\u56de\n    chooseFile(file){console.log(file)},\n    \/\/@success \u76d1\u542c\u4e0a\u4f20\u6210\u529f\uff0c\u4f1a\u8fd4\u56de\u4e0a\u4f20\u6587\u4ef6\u8def\u5f84\uff0c\u8fd9\u4e2a\u53ef\u80fd\u662f\u4e2a\u6570\u7ec4\uff0c\u5177\u4f53\u4e0d\u6e05\u695a\uff0coss\u5b98\u65b9\u6587\u6863\u7ed9\u7684\u662f\u4e2a\u6570\u7ec4\uff0c\u7ec4\u4ef6\u62ff\u5230\u8fd4\u56de\u503c\u5982\u679c\u662f\u6570\u7ec4\u4f1a\u8fd4\u56de\u6570\u7ec4\uff0c\u5982\u679c\u6570\u7ec4\u4e3a\u4e00\u9879\u4f1a\u76f4\u63a5\u8fd4\u56de\u6587\u4ef6\u5730\u5740\u5b57\u7b26\u4e32\n    successFile(urls){console.log(urls)}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u5929\u540e\u7aef\u8dd1\u8fc7\u6765\u8bf4\u963f\u91ccoss\u89c6\u9891\u4e0a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb<\/title>\n<meta name=\"description\" content=\"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb\" \/>\n<meta property=\"og:description\" content=\"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\/\" \/>\n<meta property=\"og:site_name\" content=\"\u6728\u5934\u4eba\u4e0b\u58eb\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-10T05:52:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-21T10:08:38+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-1024x408.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6728\u5934\u4eba\u4e0b\u58eb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/log.aileme.top\/#website\",\"url\":\"https:\/\/log.aileme.top\/\",\"name\":\"\u6728\u5934\u4eba\u4e0b\u58eb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/log.aileme.top\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-CN\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#primaryimage\",\"url\":\"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8.png\",\"contentUrl\":\"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8.png\",\"width\":2162,\"height\":862},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#webpage\",\"url\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/\",\"name\":\"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb\",\"isPartOf\":{\"@id\":\"https:\/\/log.aileme.top\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#primaryimage\"},\"datePublished\":\"2022-05-10T05:52:30+00:00\",\"dateModified\":\"2022-07-21T10:08:38+00:00\",\"author\":{\"@id\":\"https:\/\/log.aileme.top\/#\/schema\/person\/c33501000371413e0c203d81fa32cfef\"},\"description\":\"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\",\"breadcrumb\":{\"@id\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#breadcrumb\"},\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/log.aileme.top\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/log.aileme.top\/#\/schema\/person\/c33501000371413e0c203d81fa32cfef\",\"name\":\"\u6728\u5934\u4eba\u4e0b\u58eb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\/\/log.aileme.top\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/131652157653_.pic_-e1652157803591-150x150.jpg\",\"contentUrl\":\"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/131652157653_.pic_-e1652157803591-150x150.jpg\",\"caption\":\"\u6728\u5934\u4eba\u4e0b\u58eb\"},\"sameAs\":[\"http:\/\/log.aileme.top\"],\"url\":\"https:\/\/log.aileme.top\/index.php\/author\/songhb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb","description":"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\/","og_locale":"zh_CN","og_type":"article","og_title":"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb","og_description":"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6","og_url":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6\/","og_site_name":"\u6728\u5934\u4eba\u4e0b\u58eb","article_published_time":"2022-05-10T05:52:30+00:00","article_modified_time":"2022-07-21T10:08:38+00:00","og_image":[{"url":"http:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8-1024x408.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u6728\u5934\u4eba\u4e0b\u58eb","Est. reading time":"5\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/log.aileme.top\/#website","url":"https:\/\/log.aileme.top\/","name":"\u6728\u5934\u4eba\u4e0b\u58eb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/log.aileme.top\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-CN"},{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#primaryimage","url":"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8.png","contentUrl":"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/WeChatc63f53353de961f2368183006442eaa8.png","width":2162,"height":862},{"@type":"WebPage","@id":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#webpage","url":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/","name":"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6 - \u6728\u5934\u4eba\u4e0b\u58eb","isPartOf":{"@id":"https:\/\/log.aileme.top\/#website"},"primaryImageOfPage":{"@id":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#primaryimage"},"datePublished":"2022-05-10T05:52:30+00:00","dateModified":"2022-07-21T10:08:38+00:00","author":{"@id":"https:\/\/log.aileme.top\/#\/schema\/person\/c33501000371413e0c203d81fa32cfef"},"description":"vue+elementui\u963f\u91ccoss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6","breadcrumb":{"@id":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#breadcrumb"},"inLanguage":"zh-CN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/log.aileme.top\/index.php\/2022\/05\/10\/vueelementui%e9%98%bf%e9%87%8coss%e6%96%ad%e7%82%b9%e7%bb%ad%e4%bc%a0%e7%bb%84%e4%bb%b6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/log.aileme.top\/"},{"@type":"ListItem","position":2,"name":"Vue+ElementUi\u963f\u91ccOss\u65ad\u70b9\u7eed\u4f20\u7ec4\u4ef6"}]},{"@type":"Person","@id":"https:\/\/log.aileme.top\/#\/schema\/person\/c33501000371413e0c203d81fa32cfef","name":"\u6728\u5934\u4eba\u4e0b\u58eb","image":{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/log.aileme.top\/#\/schema\/person\/image\/","url":"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/131652157653_.pic_-e1652157803591-150x150.jpg","contentUrl":"https:\/\/log.aileme.top\/wp-content\/uploads\/2022\/05\/131652157653_.pic_-e1652157803591-150x150.jpg","caption":"\u6728\u5934\u4eba\u4e0b\u58eb"},"sameAs":["http:\/\/log.aileme.top"],"url":"https:\/\/log.aileme.top\/index.php\/author\/songhb\/"}]}},"_links":{"self":[{"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":2,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.aileme.top\/index.php\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}