Home > front end >  Why the Vue v - if doesn't work?
Why the Vue v - if doesn't work?

Time:02-06

Started groping Vue, use when using v - if there is a problem, want to achieve a click on the text links show hidden form, but the v - if judgment is always doesn't work, want to ask how to solve, the following code
 & lt; El - form: model="form" v - if="is_queryinfo==true" & gt; 








 data: {
Is_queryinfo: false,
Form: {
Query: "'
Training_method: Number,
}
},
Methods: {
OnQuery () {
Var _this=this;
_this. Is_queryinfo=true;
_this $forceUpdate ();
The console. The log (_this. Is_queryinfo);
}
}

CodePudding user response:

If above all is judge true and false, it is not necessary to judgment again in the v - if true, v - if="is_queryinfo", secondly, vue is scope, where did your el Settings, where the vue grammar is effective

CodePudding user response:

Look from your hair of the code, first of all, you have to adjust the code:
 


 
Data: {
Is_queryinfo: false,
Form: {
Query: "'
Training_method: 0,//with specific values, specific Number have a definition, didn't you define complains
}
},

Finally, you begin to look at the console, with or without an error,

CodePudding user response:

Comprehensive upstairs, you don't have a point of this problem, here also don't spare the var _this=this

CodePudding user response:

 


<script SRC="https://cdn.jsdelivr.net/npm/vue" & gt; </script>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" & gt;
<script SRC="https://unpkg.com/element-ui/lib/index.js" & gt; </script>

<body>










<script>
Var app=new Vue ({
El: '# app,
Data: {
Is_queryinfo: false,
Form: {
Query: "'
Training_method: null,
}
},
Methods: {
OnQuery () {
Var _this=this;
_this. Is_queryinfo=true;
//_this $forceUpdate ();
The console. The log (_this. Is_queryinfo);
}
}
})
</script>


  • Related