I'm trying to come up with a method to scan the DOM for a specific element that has a class name of 'amp'. Once found, I would like to create a new Vue instance and utilize the data attributes in the HTML as values for data(). Would a loop be necessary for this task?
Is this achievable and what would be the recommended approach?
Thank you.
Sample HTML:
<div class="amp" id="vue" data-contentDeliveryUrl="www.urlexample.com" data-encodedQuery="=query234" data-cidItem="555-555-555"></div>
<div class="amp" id="vue" data-contentDeliveryUrl="www.urlexample.com" data-encodedQuery="=query123" data-cidItem="666-666-666"></div>
index.js
Illustration of a new instance
new Vue({
el: '#vue',
data() {
return {
contentDeliveryUrl: contentDeliveryUrl,
encodedQuery: encodedQuery,
cidItem: cidItem
}
},
render: h => h(Page)
})