I want to show the update button when the userId matches with one of the previous users & if the userId & one of the previous users doesn't match then it will show the submit button.
I am trying this way---
new Vue({
el: '#app',
data: function() {
return {
userId:1,
previousUsers:[1,2],
}
},
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div v-for="(previousUser,i) in previousUsers" :key="i" class="text-center mt-3">
<button v-if="previousUser == userId" class="btn btn-primary" @click="update">Update</button>
<button v-if="previousUser == !userId" class="btn btn-primary" @click="add">Submit</button>
</div></div>
In my way the submit button doesn't show if I change the userId to "3". How to solve this?