I see previous questions about the same problem faced me, but I try to solve it based on the solution of the questions! but it does not work
In my <template>
:
<modal name="MyModal" >
<span class="myClass" id="visible">visible</span>
</modal>
In my <script>
:
export default {
name: "myProject",
data: function() {
return {}
},
methods:
Open_EditTask: function() {
this.$modal.show("MyModal");
this.CurrentTask = this.MyTask;
if ( app.EditTask.visible == true ) { document.getElementById('visible').innerHTML = 'visible'; }
else { document.getElementById('visible').innerHTML = 'hidden'; }
}
}
I used modal
plugin to create the modal.
My problem is when the modal opened .. the text not changed based on the app.EditTask.variable
value, but when I try to print the value of it .. it shows me the value of it either true or false.
Error message:
Uncaught TypeError: Cannot set property 'innerHTML' of null
Why do you not use computed, it's very easy.
Template:
<modal name="MyModal" >
<span class="myClass" id="visible"> {{ isVisible }} </span>
</modal>
Javascript:
export default {
name: "myProject",
data: function() {
return {}
},
methods:{
Open_EditTask: function() {
..
}
},
computed: {
isVisible(){
return app.EditTask.visible ? 'visible' : 'hidden';
}
}
}
Template:
<modal name="MyModal" >
<span :class="{myClass: true, hidden: !isVisible, visible: isVisible}" id="visible"></span>
</modal>
Javascript:
export default {
name: "myProject",
data: function() {
return {}
},
methods:{
Open_EditTask: function() {
..
}
},
computed: {
isVisible(){
return app.EditTask.visible;
}
}
}
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.