์๋ ํ์ธ์ ์ฌ๋ฌ๋ถ,
๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ ๋ฉ์์ง๊ฐ ๋ํ๋ฉ๋๋ค.
error TS2339: Property 'show' does not exist on type 'Element | Vue | Vue[] | Element[]'
๋ค์๊ณผ ๊ฐ์ ์ค์ ๊ฐ๋ฆฌํต๋๋ค.
this.$refs['myDialog'].show()
์ด show
๋ vue-class-component๋ฅผ ์ฌ์ฉํ์ฌ TypeScript์์ ๊ตฌํํ ๋ฉ์๋์
๋๋ค. Vue๋ฅผ ํ์ฅํ๋ ํด๋์ค์ ์์ต๋๋ค. ๋๋ ./types/vue.d.ts ์ฌ๊ธฐ ์์ ๋ผ์ธ์ ์ฐพ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ์ ๋ค๋ฆญ์ ์ฌ์ฉํ์ฌ ์์ ํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
readonly $refs: { [key: string]: [V extends Vue] | Element | Array<V extends Vue> | Array<Element>};
ํ์ง๋ง ๊ทธ๋ ๊ฒ๋ง ํ๋ค๊ณ ๋๋ ๊ฒ์ ์๋๋ค.
๋๊ตฌ๋ ์ง ๊ทธ๊ฒ์ ์ฌ๋ฐ๋ฅด๊ฒํ๋ ๋ฐฉ๋ฒ์ ์๊ณ ์์ต๋๊น?
๊ฐ์ฌ ํด์!
<YourComonent>this.$refs
์ ์บ์คํ
ํ๊ฑฐ๋ $refs
๋ฅผ ๊ตฌ์ฒดํํด์ผ ํฉ๋๋ค.
https://github.com/HerringtonDarkholme/av-ts/wiki/FAQ#2 -property-reification
๊ทํ์ ์ค๋ช ์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ์๋ ค์ฃผ์ง ์์ต๋๋ค. ๋ต๋ณ์ ๋จ๊ณ๋ณ๋ก ๋ณด์ฌ์ฃผ์ธ์. pls.
ts+ vue์ ๋ํด ์ ๋ง ํผ๋์ค๋ฝ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
<YourComonent>this.$refs
์ ์บ์คํ ํ๊ฑฐ๋$refs
๋ฅผ ๊ตฌ์ฒดํํด์ผ ํฉ๋๋ค.https://github.com/HerringtonDarkholme/av-ts/wiki/FAQ#2 -property-reification