Motomichi Works Blog

モトミチワークスブログです。その日学習したことについて書いている日記みたいなものです。

VueのOptionsAPIのときに取得していたthis.$elはCompositon APIではどのように取得するのだろうかという話

参考にさせていただいたページ

どうやるか

vue.js - Vue 3 Composition API - How to get the component element ($el) on which the component is mounted? - Stack Overflow」によると、ref属性で参照するらしいです。

OptionsAPIではできていた以下のような記述はどうやらできないみたいですね。

this.$el.querySelector('.example');