Answer the question
In order to leave comments, you need to log in
How to solve an error with an event bind on a component?
There is a custom button component
import { Component, Prop } from 'vue-property-decorator';
import { VueComponent } from '@/shims-vue';
import './Button.less'
interface Props {
tool?: boolean,
wide?: boolean
}
@Component
export default class Button extends VueComponent<Props> {
@Prop(Boolean) tool?: string;
@Prop(Boolean) wide?: boolean;
get className() {
const wide = this.wide ? 'button_wide' : ''
const tool = this.tool ? 'button_tool' : ''
return ['button', wide, tool].join(' ').trim()
}
render() {
return (
<button class={this.className} onClick={() => this.$emit('onClick')}>
{ this.$slots.default }
</button>
)
}
}
<Button
wide={i === arr.length}
onClick={this.remoteInputNumber(num)}
>
{num}
</Button>
No overload matches this call.
Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): Button', gave the following error.
Type '{ wide: boolean; onClick: number; }' is not assignable to type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.
Property 'onClick' does not exist on type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.
Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): Button', gave the following error.
Type '{ wide: boolean; onClick: number; }' is not assignable to type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.
Property 'onClick' does not exist on type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.
Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): Button', gave the following error.
Type '{ wide: boolean; onClick: number; }' is not assignable to type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.
Property 'onClick' does not exist on type 'Props & { key?: string | undefined; class?: string | { [key: string]: string; } | CSSClass[] | undefined; }'.ts(2769)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question