I am working on a project with Vue.js and I use components most of the time, but sometimes I would just like to add some Vue.js syntax without completely creating a component.
Because I do not use the render like you normally would the entire HTML content that Vue attaches to is not being overwritten, allowing me to sprinkle
some Vue.js syntax on existing HTML.
new Vue({
el: '#vue',
name: 'Vue root',
data: {
store
},
components: {
Example
}
});
An example of adding some Vue.js syntax to existing HTML would be; keeping 2 inputs in sync with each other for example:
Form one on index.html
<input type="text" attributes... v-model="store.arrival">
Form two on index.html
<input type="text" attributes... v-model="store.arrival">
Before I introduced the store I got a message saying something along the lines of:
[Vue warn]: Property or method "arrival" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in root instance)
This led me to introducing this store because I do not want to bloat the data property of my root component in that file by rather keep an overview of these floating in space(because they do not belong to a component)
properties.
I love the ability to still add Vue syntax to existing HTML but this feels like bad practice.
Is there a better way to store these variables than in store(which can get crowded pretty fast)? Or should I actually just move everything into components? This also leads to problems because than I am forced to transform things like PHP variables to Javascript if I need them.
Hopefully it is clear what I mean, thanks for reading and I you need more info let me know.
Cheers.