在我的react.js應(yīng)用程序中上傳之前,我試圖更改文件名:這是方法:onInputChange = (e) =>{ let newFileName='dp'; if(e.target.files.length!==0){ this.state.file=e.target.files[0]; Object.defineProperty(this.state.file.name, 'name', { writable: true, value: newFileName }); console.log(this.state.file); }};但問題是,每當(dāng)調(diào)用此函數(shù)時,我都會收到一條錯誤消息: Object.defineProperty 在非對象上調(diào)用如何解決?
Object.defineProperty 在我的 react.js 應(yīng)用程序中調(diào)用非對象
有只小跳蛙
2021-10-21 14:59:04