I don't know the flow of treatment.
I am studying vue.js by referring to http://gihyo.jp/dev/serial/01/vuejs/0002?page=2.
<divid="example" v-bind:style="{'border':(isValid?':'1px solid red')}">
<p>Name {{name}}</p>
<p>
<input type="text" v-on:input="updateName($event)">
</p>
<pv-show="!isValid">
Please enter a name
</p>
<pv-show="isValid">
<button v-on:click="sendData">Send</button>
</p>
</div>
and
varvm = new Vue({
el: '#example',
data: {
name: '' ,
},
computed: {
isValid: function() {
return this.name.length>0;
}
},
methods: {
updateName:function(event){
this.name=event.target.value;
},
sendData: function() {
alert(this.name);
}
}
});
window.vm=vm;
and so on.Anything you don't understand is
com When is the computed called?
②
updateName:function(event){
this.name=event.target.value;
}
Why is this from this.name? Where does event.target.value refer to?
That's it.
I have no idea about に, but is it when v-bind:style="{'border':(isValid?':'1px solid red')}"
is called?
< When is the isValid
function called instead of computed
?I think it means that
Invoked roughly when the Vue object is initialized and when the name
value changes.
<this
is required because updateName
is called so that Vue.js is this===vm
.
event.target.value
is the value entered in the input element.
If you are studying Vue.js, it would be more efficient and accurate to read official documents instead of old information.
For example, for re, Calculation properties and watcher—Vue.js have almost all the answers.
© 2024 OneMinuteCode. All rights reserved.