async和await必須成對出現,示例:javascript
function file2txtArr(file) { var fr = new FileReader; fr.readAsText(file); return new Promise((resolve) => { fr.onload = function() { resolve(this.result.split('\n')); } }); } async function(){ let file = this.$refs.upload.$refs['upload-inner'].$refs.input; let loginWxArr = await file2txtArr(file.files[0]); }