Vue <script setup> reactivity not working

Im trying the <script setup> syntax in vue and wondering why reactivity is not working. What’s wrong here? <template> <button @click="changeButtonText">{{ buttonText }}</button> </template> <script setup> import { ref } from ‘vue’ let buttonText = ref("Foo") function changeButtonText() { buttonText = "Bar" } </script> Tried without ref(). Tried with buttonText = ref("Bar"). No effect >Solution… Read More Vue <script setup> reactivity not working

Using V-IF inside css attribute

I am trying to use different class based on true or false. Here’s my approach: if(i == 0) assign class name d-block, else assign class name d-none <div class="card :v-if=’steps == 1 ? d-block ? d-none’"> </div> >Solution : Try doing this instead <div :class="{card: ‘steps === 1’ ? ‘d-block’ : ‘d-none’}"></div>

How to create a new object instead of assigning a reference to the existing object in `Vue3 Option Api`

props:{ variants:{ type: Array, default: [] } options:{ type: Array, default: [] }, }, data(){ return{ item:{ quantity: 1, options: this.options, }, } }, I have a problem with this code: When i change item.options value also options get changed because as i understand, i am just assigning a reference to options. How to create… Read More How to create a new object instead of assigning a reference to the existing object in `Vue3 Option Api`

Vue: timer value doesn't update when using setInterval

I have the following code for updating the number of seconds elapsed and displaying it: <template> <div> {{timerValue}} </div> </template> <script> export default { name: "App", components: { }, data() { return { timerValue: "" } }, created() { let seconds = 0; this.timerValue = seconds; setInterval(function() { seconds++; }) } }; </script> However the… Read More Vue: timer value doesn't update when using setInterval

Vue can't receive subscribe to event from child component in to parent component

I have two components – parent and child. The child emits an event, which should trigger a console output in a parent component. However nothing is printed in console. TestPage.vue: <template> <div v-on:hidden="hiddenEvent"> <TestComponent></TestComponent> </div> </template> <script> import TestComponent from "@/app/test/TestComponent"; export default { name: "TestPage", components: {TestComponent}, methods: { hiddenEvent() { console.log("hiddenEvent"); } }… Read More Vue can't receive subscribe to event from child component in to parent component

Why is this computed() supposed to filter a listof items if anything is writen in a text input not working?

I have this super simple vue3 App, it works kinda like a to-do app, you add an item, and it pushes into an Array which is displayed in Screen. I set a <input/ type="text" with a v-model="" and made a computed which works over that array. The logic is very simple, it has a .filter… Read More Why is this computed() supposed to filter a listof items if anything is writen in a text input not working?