JavaScript/typescript/error:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 标题文字 == * Property 'call' does not exist on type 'object' *: 在项目中,我使用了 <syntaxhighlight lang="javascript" inline> await this.axios.call(…”
 
Kangkk​(留言 | 贡献)
第1行: 第1行:
== 标题文字 ==
== 标题文字 ==
* Property 'call' does not exist on type 'object'
* Property 'call' does not exist on type 'object'
*: 在项目中,我使用了 <syntaxhighlight lang="javascript" inline>
*: 在项目中,我使用了 <syntaxhighlight lang="typescript" inline>
await this.axios.call(this.context, {</syntaxhighlight> 抛出此错误,axios 的设定是
await this.axios.call(this.context, {</syntaxhighlight> 抛出此错误,axios 的设定是
*: <syntaxhighlight lang="javascript">
*: <syntaxhighlight lang="typescript">
interface HttpInterface {
interface HttpInterface {
   axios: object;
   axios: object;
   context?: Record<string, unknown>;
   context?: Record<string, unknown>;
}</syntaxhighlight>
}</syntaxhighlight>
*: 如果改成 <code>axios: any</code> 可消除错误
*: 如果改成 <code>axios: any</code> 可消除错误,又或者这样设置
*: <syntaxhighlight lang="typescript">
interface AxiosPropertyCall {
  call: any
}
 
interface HttpInterface {
  axios: AxiosPropertyCall;
  context?: Record<string, unknown>;
}
 
await this.axios.call(this.context</syntaxhighlight>

2020年8月28日 (五) 03:05的版本

标题文字

  • Property 'call' does not exist on type 'object'
    在项目中,我使用了 await this.axios.call(this.context, { 抛出此错误,axios 的设定是
    interface HttpInterface {
      axios: object;
      context?: Record<string, unknown>;
    }
    
    如果改成 axios: any 可消除错误,又或者这样设置
    interface AxiosPropertyCall {
      call: any
    }
    
    interface HttpInterface {
      axios: AxiosPropertyCall;
      context?: Record<string, unknown>;
    }
    
    await this.axios.call(this.context