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

Custom methods through vue-class-component are not recognized with $ref #4773

Closed
Yc-Chen opened this issue Jan 23, 2017 · 3 comments
Closed

Comments

@Yc-Chen
Copy link

Yc-Chen commented Jan 23, 2017

Hi all,

I have got an error message like this:

error TS2339: Property 'show' does not exist on type 'Element | Vue | Vue[] | Element[]'

It points to a line like this:

this.$refs['myDialog'].show()

This show is a method implemented in TypeScript using vue-class-component. It is in a class that extends Vue. I located the line in ./types/vue.d.ts here.

I guess it should be modified using generics like this:

readonly $refs: { [key: string]: [V extends Vue] | Element | Array<V extends Vue> | Array<Element>};

But it doesn't work by just doing that.

Does anyone know how to do it right?

Thanks!

@HerringtonDarkholme
Copy link
Member

You either need cast it <YourComonent>this.$refs or reify $refs.
https://github.com/HerringtonDarkholme/av-ts/wiki/FAQ#2-property-reification

@plh97
Copy link

plh97 commented May 24, 2019

your descript don't let me know how to fix this problem. show the answer step by step, pls.

@plh97
Copy link

plh97 commented May 24, 2019

really confuse about ts+ vue

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