The task is simple, if the goods are in stock, there should be a message "In Stock", and vice versa. You can do this through v-if like this.
new Vue({ el: "#app", data: { inStock: true } }) <style> span { font-size: 30px; font-weight: 700; } </style> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script> <div id="app"> <span v-if="inStock">Π Π½Π°Π»ΠΈΡΠΈΠΈ</span> <span v-else>ΠΠ΅Ρ Π² Π½Π°Π»ΠΈΡΠΈΠΈ</span> </div> And it is possible through observation of the property and redefinition of the value displayed inside the block. So:
new Vue({ el: "#app", data: { message: "Π Π½Π°Π»ΠΈΡΠΈΠΈ", inStock: true }, watch: { inStock: function () { if (this.inStock) { this.message = "Π ΠΌΠ°Π³Π°Π·ΠΈΠ½Π΅"; } else { this.message = "ΠΠ΅Ρ Π² Π½Π°Π»ΠΈΡΠΈΠΈ"; } } }, methods: { change: function () { this.inStock = this.inStock ? false:true; } } }) span { font-size: 30px; font-weight: 700; } button { display: block; } <div id="app"> <span>{{message}}</span> <button @click="change">ΡΠΌΠ΅Π½ΠΈΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅</button> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script> With the button I had to add to show how the value changes. Which approach is more correct. In the 1st it is embarrassing to add or remove a DOM node (as I understand it, a span that does not meet the condition is removed from the DOM