4
The problem is, I have a switch made with label and input checkbox and it has a default value that comes from date of my instance of Vue.
var app = new Vue({
el: '#app',
data: {
slcModalidad: 0,
chkPosNet: true,
},
<label for="chkAllowPosNet" class="label-chk-allow">
<input type="checkbox" id="chkAllowPosNet" name="chkAllowPosNet" v-model="chkPosNet">
<div class="allow-text"></div>
<div class="allow-toggle"></div>
</label>
However I need the default value of the variable chkPosNet pass a condition to determine whether it is true or false, which in my example would be if the slcModalidad is greater than 2. What would be the best way to do this?
I thought I’d leave the chkPosNet as null and create a method for checking, but I got confused whether I do in methods, computed, Mounted.... or whether I can do a v-if for v-model.
can tell me the advantage of using computed in place of Watcher?
– haykou
It is possible (I am not sure) that the Watcher weighs more. Computed properties are the feature that Vue offers to do exactly what you want, while Watcher is a more generic thing.
– bfavaretto