Hi, how would you handle the shortcode beeing used twice (or more often - after all its up to the wordpress user)? You would have the same element id twice. I am trying to find a solution in which I bind it to a class but can't get it running:
'''
let elements = document.getElementsByClassName('conversionform')
for(var i = 0; i < elements.length; i++){
new Vue({
store,
render: h => h(App)
}).$mount( ???? )
}
Hey Dennis!
I didn't had time to expand this little tut and i didn't tested it with WP but a maybe better solution would be to create a shortcode with a component tag of the vue component. So that you would create a string like this:
$str= "<vue-component/>";
To mount the vue-app to the whole page you could set an id to a global tag like the body tag. I think this could be even a better solution for the integration of vue.js in wordpress. I'm still working on this to create a simple solution for using vue tags. I hope i can put this way to an article soon.
In addition you have to handle the script imports, otherwise it could be that it would be imported every time the shortcode is used, but i think the browser is smart enough to handle that.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, how would you handle the shortcode beeing used twice (or more often - after all its up to the wordpress user)? You would have the same element id twice. I am trying to find a solution in which I bind it to a class but can't get it running:
'''
let elements = document.getElementsByClassName('conversionform')
for(var i = 0; i < elements.length; i++){
new Vue({
store,
render: h => h(App)
}).$mount( ???? )
}
Hey Dennis!
I didn't had time to expand this little tut and i didn't tested it with WP but a maybe better solution would be to create a shortcode with a component tag of the vue component. So that you would create a string like this:
To mount the vue-app to the whole page you could set an id to a global tag like the body tag. I think this could be even a better solution for the integration of vue.js in wordpress. I'm still working on this to create a simple solution for using vue tags. I hope i can put this way to an article soon.
In addition you have to handle the script imports, otherwise it could be that it would be imported every time the shortcode is used, but i think the browser is smart enough to handle that.