Skip to main content

All Questions

4 votes
1 answer
2k views

why do I get this error when I try to use multiple defineModels in vue.js?

I am trying to use the v-model directive on two input elements. However, I am getting the following error: duplicate model name "modelValue". Below I show the code that generates this error: ...
William Pineda MHA's user avatar
7 votes
1 answer
11k views

How to use defineModel (in Vue 3.4) for uses other than inputs

The examples given for defineModel in the Vue docs all relate to uses for data inputs. I was wondering if this construct could also be used elsewhere, thus avoiding the somewhat cumbersome props/emit ...
quilkin's user avatar
  • 1,457
0 votes
1 answer
4k views

Vue watchers and reactivity

In my vue app, I want to watch route changes, and then react to the change. Here is an example where I simulate a route change. <script setup> import { ref, watch } from 'vue' import { ...
Arti-Art's user avatar
0 votes
1 answer
30 views

VueJS passing parameter to bound property

I want to track the state of several buttons without having a tracker variable and function for each. So I want to pass a parameter through to a computed property, something like this: <div class=&...
Andy's user avatar
  • 2,150
-1 votes
1 answer
85 views

Blank background-image in vue.js

For a website, i want 70% of the page to be covered with an image. However the image is just blank. I use Vue.js as my frontend. Here is the code that results in a blank space: <script setup lang=&...
Clyon97's user avatar
  • 59
0 votes
1 answer
983 views

Is there a way to pass a Object as param to router in VueJS 3 (Composition API + script setup)?

In this project, there's the user which is a js object, like this: const user = { "ID": id, "NAME": name, "EMAIL": email, ... } And here's the router on VueJS: { ...
user avatar
0 votes
1 answer
499 views

How to load a dynamic image from a url in Nuxt3?

I have a nuxt 3 component which fails to load dynamic image that i'm getting from a specific URL(auth0 images). My template looks like so: <template> <img class="h-28 w-28 rounded-...
George Marwanqana's user avatar
4 votes
1 answer
3k views

Is there any problem if I use two onMounted() per one component?

I have only seen examples of one onMounted() per one component. I'd like to use onMounted() for each feature. Is there any problem? MyComponent.vue <script setup> import { onMounted } from 'vue';...
decoy's user avatar
  • 171
0 votes
2 answers
2k views

Vue 3 composition API pass array props through many children

I need to pass an array from component A (App.vue) through component B to component C. What I do is this (this first step works, just read it to understand): // A.vue <script setup> import B ...
grimoiredark's user avatar
1 vote
4 answers
4k views

Why doesn't the component tag in Vue3 work properly for dynamically rendering components?

I'm just learning Vue and trying to learn dynamic rendering using the component tag. What is the problem with this code? No errors are displayed in the console, but clicking on the buttons still does ...
mrcrazyog's user avatar
0 votes
1 answer
494 views

Why is my bound data in a Vue 3 form not being updated when printed on the console via a function?

I have created a form component in Vue 3 where I am trying to bind a reference object to input elements and from my understanding of two-way binding and how Vue behaved for my past works, I expected ...
Muhtasim Fuad Showmik's user avatar
1 vote
4 answers
450 views

Setting input attributes with props and <script setup>

Is it possible to set a form input type using a prop? The below does not seem to work, any others ways to do this? For example <script setup> defineProps({ InputType: String, InputId: String,...
sgledhill's user avatar
1 vote
2 answers
1k views

Can I import a component in Vue.js with path based on prop?

I am using the Material design Icons library for Vue.js. This library contains a folder and every icon is a single file component in that folder. I have another component, ToolbarButton, that has a ...
Štěpán Žák's user avatar
0 votes
2 answers
519 views

Vue component's button callback: Cannot read properties of undefined

Using Vue3+typescript, I'm trying to use a library called gtag-vue to send google analytics events to my account. The idea is that in a Vue component, when the user clicks a div, I'll send a custom ...
lpares12's user avatar
  • 4,033
5 votes
0 answers
684 views

How to unit test a vue script setup component?

We want to use vue composition api using the script setup in our company. How would one write unit tests for a script setup component? We're using Vue 2.7.14 and vitest if that matters.
Lucas Venturini's user avatar

15 30 50 per page
1
2 3 4 5 6