In my project, I am utilizing Vue 3.0.2 by loading it through CDN with the following code:
<head>
...
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f7818292b7c4d9c7d9c5">[email protected]</a>"></script>
</head>
I am wondering how I can access an HTML element within my Vue component when importing the library via CDN. In plain JavaScript, I would use
document.getElementById('element')
.
Previous discussions on this platform suggest that using $this.el.querySelector
should do the trick, but I seem to lack access to that function. Could this be due to importing Vue via CDN?
This is what my component structure looks like...
const app = Vue.createApp({
data() {
return {
// data members.
}
},
methods: {
// method definitions.
} });
app.mount('#app')
Appreciate any help and guidance!