Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何暴露函数给父组件这个写法,有解吗? #626

Open
Charlie500 opened this issue Nov 21, 2022 · 5 comments
Open

请问如何暴露函数给父组件这个写法,有解吗? #626

Charlie500 opened this issue Nov 21, 2022 · 5 comments

Comments

@Charlie500
Copy link

image

@funny-family
Copy link

@Charlie500

ctx.expose({
  myClick,
});

@Charlie500
Copy link
Author

Charlie500 commented Dec 6, 2022

you can paste my code to your ide , expose is not defined in ctx @funny-family

@funny-family
Copy link

@Charlie500, that is why.

export interface FunctionalComponent<P = {}, E extends EmitsOptions = {}>
  extends ComponentInternalOptions {
  // use of any here is intentional so it can be a valid JSX Element constructor
  (props: P, ctx: Omit<SetupContext<E>, 'expose'>): any
  props?: ComponentPropsOptions<P>
  emits?: E | (keyof E)[]
  inheritAttrs?: boolean
  displayName?: string
  compatConfig?: CompatConfig
}

Try to console log ctx, if expose exists inside this object it must be mistake in type definition of Functional Component.

@funny-family
Copy link

funny-family commented Dec 8, 2022

@Charlie500, or you can try use defineExpose

@abearxiong
Copy link

纯函数不行。我刚看了一下代码,你定义到defineComponent里面的setup应该可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants