我安装了axios,但是我在代码中导入axios一旦出错“axios.get”的字样就出下面的错误:
Compile Result] The regular property 'item' cannot be assigned to the @ObjectLink property 'item'.
[Compile Result] [webpack-cli] TypeError: Cannot read properties of undefined (reading 'replace')
[Compile Result] at processNodeModulesFile (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\lib\gen_abc_plugin.js:1:8295)
[Compile Result] at processJsModule (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\lib\gen_abc_plugin.js:1:10445)
[Compile Result] at D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\lib\gen_abc_plugin.js:1:13831
[Compile Result] at Set.forEach (<anonymous>)
[Compile Result] at handleFullModuleFiles (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\lib\gen_abc_plugin.js:1:13052)
[Compile Result] at GenAbcPlugin.handleFinishModules (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\lib\gen_abc_plugin.js:2:3272)
[Compile Result] at Hook.eval [as callAsync] (eval at create (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:40:1)
[Compile Result] at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\node_modules\webpack\node_modules\tapable\lib\Hook.js:18:14)
[Compile Result] at Compilation.finish (D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\node_modules\webpack\lib\Compilation.js:2714:28)
[Compile Result] at D:\huawei\SDK\openharmony\9\ets\build-tools\ets-loader\node_modules\webpack\lib\Compiler.js:1182:19
下面是我的代码:我什么都没敢写,我发现只要出现axios就会有上面的错误?
getShopListAxios():Promise<ShopInfo[]>{
return new Promise((resolve,reject)=>{
axios.get(
`${this.baseURL}/shops`,
{
params:{pageNo:this.pageNo,pageSize:3}
}
)
})
}
本文参与了思否 HarmonyOS 技术问答马拉松,欢迎正在阅读的你也加入。
麻烦检测一下
npm install axios
来安装。