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>
<pv-show="!isValid">
Please enter a name
</p>
</div>
and to js
varvm = new Vue({
el: '#example',
data: {
name: '' ,
},
computed: {
isValid: function() {
return this.name.length>0;
}
}
});
window.vm=vm;
"However, I do not understand the meaning of this isValid? and ""!isValid""When I move these codes, the red box and the letter "Please enter your name" are always displayed, but I thought isValid? and !isValid would be a match, but I didn't understand that these two were always displayed.
html vue.js
isValid?'': '1px solid red'
returns '
if isValid
is true and false
returns '1px solid red'
.
In other words, if isValid==false
, a red frame is displayed.
!isValid
is the reversal of true
and false
, so isValid==false
displays 名前Please enter a name を.
© 2024 OneMinuteCode. All rights reserved.