查看“︁JavaScript/typescript/error”︁的源代码
来自康健生活
←
JavaScript/typescript/error
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 标题文字 == * Property 'call' does not exist on type 'object' *: 在项目中,我使用了 <syntaxhighlight lang="typescript" inline> await this.axios.call(this.context, {</syntaxhighlight> 抛出此错误,axios 的设定是 *: <syntaxhighlight lang="typescript"> interface HttpInterface { axios: object; context?: Record<string, unknown>; }</syntaxhighlight> *: 如果改成 <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> * Property 'username' has no initializer and is not definitely assigned in the constructor. *: 缺少初始化 *: <syntaxhighlight lang="typescript"> username: AccountInterface['username'] password: AccountInterface['password'] verify?: AccountInterface['verify'] constructor(props:any) { super(props) this.username = '' this.password = '' this.verify = '' }</syntaxhighlight> * Type 'Login' has no properties in common with type 'HttpParamInterface'. *: 两个类之间没有共同属性 * Cannot find name 'T' * Type 'string | number' is not assignable to type 'string'. *: 使用 tostring() * A required parameter cannot follow an optional parameter. *: 必选参数不能位于可选参数后 * Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'. *: 原代码 password 缺少默认值 *: <syntaxhighlight lang="javascript"> async fetch(username: AccountInterface['username'], password: AccountInterface['password'], httpMethod?: HttpParamInterface['httpMethod']): Promise<object> { const result: FetchData<any> = await this.axios.call(this.context, { method: httpMethod || 'POST', data: { userName: username, password: Base64.encode(password), sign: byteMd5(username, password)</syntaxhighlight> *: <syntaxhighlight lang="javascript"> async fetch(username: AccountInterface['username'], password: AccountInterface['password']='', httpMethod?: HttpParamInterface['httpMethod']): Promise<object> { const result: FetchData<any> = await this.axios.call(this.context, { method: httpMethod || 'POST', data: { userName: username, password: Base64.encode(password), sign: byteMd5(username, password)</syntaxhighlight> * 一个需求,在解构时抛错: *: <syntaxhighlight lang="javascript"> const result: FetchData<any> = await this.request.call(null, ...setHttpMethodTypeData({ method: httpMethod || 'get', url: basicsModel.queryMenuData, headers: headers })) </syntaxhighlight> *: Type 'object' must have a '[Symbol.iterator]()' method that returns an iterator
返回
JavaScript/typescript/error
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。