In my Vue app, I am retrieving content from Prismic using an API CMS. Within this content, there are certain sections enclosed in span tags with a unique class. My goal is to target those specific span nodes in Vue and apply an event listener to them.
When attempting to accomplish this task with vanilla JavaScript, the following code would suffice:
var selectedSpanElements = document.querySelectorAll('.className');
selectedSpanElements[0].style.color = "red"
However, when implementing this code in Vue, it appears to only work momentarily before Vue refreshes the DOM. Experimenting with various hooks such as mounted, beforeupdate, updated, and ready did not yield successful results.
Update: After some time, I discovered that by utilizing the HTMLSerializer, I can insert HTML code into the span tags. Nonetheless, this method only allows for standard HTML insertion and does not grant access to Vue methods.