I've seen many times Vue instance is bind on body
tag.
Other times this is bind on a div id
I'm asking when i should use body
tag or an id
tag (that limit the scope of the Vue instance).
Two examples:
new Vue({
el: 'body'
});
OR
new Vue({
el: '#a-div'
});
The key difference is that v-if conditionally renders elements and v-show conditionally displayselements. This means that v-if will actually destroy and recreate elements when the conditional is toggled. Meanwhile, v-show will always keep the element in the DOM and will only toggle its display by changing its CSS.
The v-bind directive is a Vuejs directive used to bind one or more attributes, or a component prop to an element. If that attribute is binded to our data defined in Vuejs instance then dynamically changes can be observed as data changes.
v-model is for two way bindings means: if you change input value, the bound data will be changed and vice versa. But v-bind:value is called one way binding that means: you can change input value by changing bound data but you can't change bound data by changing input value through the element.
Vuex is a state management pattern for vue. js. $t is the injected method from vue. js or Vue.
You should never use the body
tag. In fact, it raises a warning to use the body
tag.
Added a warning when mounting the root instance to body or html. This is no longer recommended in 2.0.
This is from the release notes, anyways it's incorrect, it raises an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With