For some reason (dont ask me why), I am having to reset a variable in VueJS via a template. So, In vuejs, I have this:
const someApp = new Vue({
delimiters: ['[[', ']]'],
el: '#some-app',
data: {
flag: 0,
},
methods: {
changeFlag(val) {
if (val === 0){//dumb stuff
this.flag=0;
}
else if (val ===1){
this.flag=1;
}
return this.flag;
},
...
In my template I have this:
<div :data-flag="changeFlag(0)"></div>
<p class="card-text"> User story(s):</p>
<template v-for="item in UserStories">
<ol v-if="(some_complex_logic_here_via_filters )">
<li :name="post.id + '__UA'" :data-flag="changeFlag(1)"> [[ item.something] ]] </li>
</ol>
</template>
<p v-if="(flag === 0)">No user stories found.</p>
The idea is that by excecuting changeFlag(0) and changeFlag(1) I can control the <p> tag later. However, for some reason, the browser seems to hang when I execute this. When I remove the for loop, everything seems OK - the <p> tage with no user stiries renders correctly. The error seems to be when I reset using changeFlag(1).
I am quite new to VueJS and I am wondering if there is some usage error in this...
flagwithout achangeFlag()method. It would seem to be easier...someApp.flag = val