I am trying to set a flag that can be a boolean value true
or false
based on certain conditions.
// main.js
new Vue({
el: `#app`,
render: h => h(App,{
props:{
todoID: this.dataset.id
}
})
})
my App script
export default {
name: 'App',
props: {
todoID: String,
},
data() {
return {
isDone: false // here is the initial flag
}
},
...
I created a mixin method
import Vue from "vue";
Vue.mixin({
methods: {
isCompleted() {
if (myconditions){
this.isDone = true; // I want to change the flag to true
}
},
},
});
in my template if I do {{isDone}}
I always get false, how can I change this to be reactive so it can be changed based on the conditions?
I guess myconditions
is undefine when you call isCompleted
funtion. So better to pass true
to it.
isCompleted(myconditions) {
if (myconditions){
this.isDone = true; // I want to change the flag to true
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.