DEV Community

Discussion on: Vue Application as a Wordpress Plugin

Collapse
 
dgmann profile image
DGMANN • Edited

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/>";
Enter fullscreen mode Exit fullscreen mode

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.