All Questions
Tagged with vue.js vue-composition-api
1,203 questions
0
votes
0
answers
30
views
give tab focus() on a component when rendering in vue
I have button icon which is a separate component. I need to give the tab focus on this element after page is rendered. I am using Composition API in Vue 3. I tried adding ref to this component but it ...
1
vote
2
answers
48
views
How can I render components dynamically with Vue 3?
I have a process which have many steps. Each one is implemented in a different component.
Initially I had this code:
<template>
<template v-if="process.currentStep === 0">
&...
1
vote
1
answer
42
views
What is 'effect' on Vue computed properties
If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value property, there's also .effect. I wasn't able to find any information about it, except that it's deprecated ...
0
votes
0
answers
44
views
Prohibit attributes for components in Vue Composition API
Allowance of any attributes for components creates problems for me.
Playground
For example taking this:
<script setup lang="ts">
import { ref } from 'vue';
import Checkbox from './...
0
votes
1
answer
33
views
Vue 3 get delta object of reactive updates
Consider a reactive object (or array) that is dynamically populated with data:
import { reactive, computed } from 'vue'
const entries = reactive({}) // global state beyond Template level
const docs = ...
0
votes
0
answers
54
views
My local variable is not being changed with watch in Vue.js + primevue
I have a parent component and a child component. I created a local variable in the child component to copy the parent's variable and be able to change its value. The problem is that in some ...
0
votes
1
answer
39
views
Unable to Access Methods from Dynamically Rendered Vue 3 Component Using <component :is="..."> and ref
I'm working on a Vue 3 component where I dynamically render another component using <component :is="...">. The dynamically rendered component has a method (e.g., export()) that I need ...
0
votes
1
answer
39
views
Prop is undefined in child component ref()
I've been using Vue for about 7 years now but am new to the Vue 3 Composition API.
I am having an issue with a prop value being undefined when trying to access it in a ref object.
Parent component:
&...
0
votes
0
answers
43
views
Leaflet with vue3 composition api, TypeError: fitBounds is not a function
I am using vue3, leaflet and vue-leaflet with composition api.
I want to zoomIn the map when multi markers were added.
But when I use mapRef.value?.fitBounds(bounds, { padding: [50,50] }) ,
it will ...
0
votes
0
answers
77
views
How to deal with <script-setup> component imports and eslint rules like no-unused-vars
When using Vue
composition API with <script setup>, components are just imported like
import Component from '@/components/Component.vue';
How do I keep eslint from applying the no-unused-var ...
0
votes
0
answers
49
views
Fallback an exposed in Vue Composition API?
I have a table component with an exposed:
const self = {
dispatchKeys: (e: KeyboardEvent) => (onInputKeydown(e), self),
assign, assignRow, selectCell,
selection,
columns,
get ...
1
vote
2
answers
169
views
How can I make Axios globally available in a Vue 3 application using the Composition API with TypeScript?
I've tried using provide/inject:
plugins/axios.ts:
import axios from 'axios'
import type { AxiosInstance } from 'axios'
import type { App } from 'vue'
export default {
install: (app: App, baseUrl:...
0
votes
0
answers
267
views
Vue component error handling with onErrorCaptured
We have specific components that have to be handled specially in regard to error logging. We are using Sentry and need to apply specific tags to possible errors when they are thrown in a specific ...
1
vote
1
answer
480
views
Route parameter typing error with TypeScript and unplugin-vue-router
I'm learning Vue 3 with the Composition API using TypeScript. One of the tutorials I'm doing suggests using unplugin-vue-router to autogenerate routes based on file naming/path conventions. The plugin ...
1
vote
2
answers
62
views
Get property types in Vue Composition API [duplicate]
When importing a component is it possible to get its properties type?
For example:
import MyComponent from '.my-component.vue';
const props: ComponentProps<MyComponent> = {
};
Any idea how to ...
0
votes
0
answers
66
views
Creating a scroll event to change v-app-bar color from transparent to color
I am trying to create a transparent v-app-bar that is transparent at first but then as I scroll transitions to color. There is a similar post that is using options api and window.onscroll mounted as ...
0
votes
1
answer
26
views
Infer type of callback argument into one of the returned function
I have composable function like this:
export function useAppModal(beforeOpen?: <???>) => void) {
const modal = ref()
// calling open with any arguments will be passed to beforeOpen ...
0
votes
1
answer
153
views
Return component with props from composable
In a Vue project, I have a composable that provides few useful refs to components using it.
In my application, it is very likely that whichever components use the composable, it will need to render ...
2
votes
1
answer
360
views
In Vue3 how to access a component's exposed bindings (via defineExpose) from a parent when the component was passed to a slot?
Lets say I have a Component.vue
<template>
<div>
<div class="items">
<slot name="items"></slot>
</div>
<div class="...
0
votes
1
answer
70
views
Binding Events and Functions to Dynamic Components in Vue 3
I have an array of form field like below and I wanna render dynamic form with event and function
[...{
label: "Logo",
field: "image",
component: ...
0
votes
1
answer
149
views
Are there any issues/concerns with assigning computed values to a ref property in Vue?
I'm reviewing some Vue code where the developer has assigned a computed value to a ref property. I've never seen this done before, and although it works, it seems odd to me.
Are there any potential ...
0
votes
1
answer
97
views
Computed is still dirty after getter evaluation, with dependency being set asyncronously
I have a pinia store which loads data on demand from a database (specifically Firestore, but I don't think it matters).
When the data is queried, it sets a value into a reactive Map ({ id: <id>, ...
2
votes
2
answers
371
views
Vue 3 separation of logic with setup notation and composition API
In Vue 3 (composition API with setup method), in order to separate logic, you've to create other methods outside of your setup method (which are named composition functions) :
<script>
export ...
0
votes
0
answers
54
views
LPolyline not updating with new data with Vue 3
I am making a map application using vue 3, quasar and vue-leaflet. I have gotten the map to render and I have markers able to be rendered and update the location when new data comes in. When I try to ...
1
vote
0
answers
82
views
Swiper Laravel 9 VueJs 3
I'm trying to do a swiper using laravel api vue js composition api, the swiper doesn't work, it was working at first with the template(statically using the swiper code in main.js), but when I added ...
-1
votes
2
answers
355
views
Vue js 3 search component feature
I want to create a search component with result dropdown in vue js using composition api.
The component should follow the next requirements:
Clicking on the input a request should occur, loading ...
1
vote
1
answer
495
views
How to call the methods exposed by components in slots with Vue 3 Composition API
There are some components (child component) in a slot (in parent component) and I want to call the methods on them. I tried the following steps:
Retrieve the child components as objects with useSlots
...
3
votes
1
answer
147
views
Why is a computed property necessary for reactivity in a Vue component with Pinia store?
I am storing an authenticated user of my web app (Vue and Supabase) in a Pinia store: userStore.user. My NavBar component has a login/logout link based on this state. In order to make this reactive ...
0
votes
1
answer
238
views
Internal server error: Failed to resolve import
Сomponents are not loaded. I don’t understand why. Maybe I didn't connect something somewhere?
<template>
<MainLayout></MainLayout>
</template>
<script setup>
import ...
0
votes
0
answers
221
views
Quasar table header selection value always true
I'm working with vuejs and quasar and I find something. In this component Im using quasar table with multiple selection The header selection is not working as expected. I'm trying to exclude rows with ...
2
votes
1
answer
231
views
How to acces data and methods from defineExpose in vue
`I am trying to access the method from the child component to the parent component in Vue(composition api) , I have defined the method inside the defineExpose , but not able to access it within parent
...
0
votes
1
answer
50
views
How can a container change the CSS display property of a child in the default slots?
I have a vue playground.
The container component needs to be able to control the CSS display property of an unknown number of children in the default slot.
I assume the child components will need to ...
0
votes
1
answer
106
views
How can I call an exposed function of a vue component in a default slot?
I have a vue playground.
ChildA and ChildB both expose a function called interfaceFunction.
I can call this function from App by getting a reference to the component. With the reference, I can call ...
2
votes
1
answer
87
views
How can a container change the display of a child in the default slots?
I have a vue playground.
The container component needs to be able to control the display status of an unknown number of children in the default slot.
I assume the child components will need to hold a ...
0
votes
3
answers
646
views
How to pass component as props in vue 3 composition api?
i want to pass props customActionComponent as component and need to render in child component
FlightDetail.vue
<template>
<ComponentCard
title="Flight Details"
subtitle=&...
0
votes
1
answer
54
views
img src not being set after component mount in vue
i have a component that is being mounted on a v-for loop. The mounted component has a onMount method. the method executes some code to get an img url I have located in firebase and sets the img src ...
1
vote
1
answer
939
views
Vue3 Composition API: Error: Codegen node is missing for element/if/for node. Apply appropriate transforms first when using named slots in router-view
I am currently in the process of rewriting my Vue code in all of my apps but am running into a rather annoying error that I cannot seem to decipher. Let me explain to you first what I am trying to do....
0
votes
1
answer
730
views
Reactivity Lost in Vue Composition API when Integrating TanStack Query with Vee Validate
I'm having a reactivity issue in Vue.js when trying to integrate a custom hook with TanStack Query and Vee-Validate. I've created a custom hook using @tanstack/vue-query for data fetching, which ...
0
votes
0
answers
43
views
Using <component :is,,, /> in vue to load svg
I want to use the component tag in vue composition api, in a way that give the path to my svg file I'd be able to load it on the page.
I have this problem for a while and I think there would be an ...
3
votes
2
answers
470
views
How to expose @click event handler on a slot to parent so the parent can bind it to an element passed to that slot with v-bind like in Vuetify?
First things first I use the <script setup> API.
In Vuetify components like v-menu have a slot called activator where you can put a custom element as your dropdown "button" and bind ...
1
vote
1
answer
304
views
how to use less variables in vue components?
I have imported the .less file to the vue component, but it still gives me an error.
I define the variables in base.less under assets/less.
@font-face {
font-family: 'Poppins';
src: url(../fonts/...
1
vote
0
answers
289
views
Add or Edit a form with VueJS, Pinia and the Composition API
I have two components with the App.vue in my little project. The first is a form who add or update data and the second list all data in the database in a table. And in the table i have 2 actions ...
0
votes
1
answer
59
views
How can I export an array in Vue so that the child component will know what kind of properties each element have?
I am learning Vue.
Here is the parent element
<template>
<Header />
<div class="container">
<IncomeExpenses :income="+income" :expense="+expense&...
0
votes
1
answer
888
views
Vue3 "Composition API", How to access a state or getter of a Pinia store, in a component's script section? [duplicate]
I new to Vue3 and I am building a frontend for a simple CRUD inventory API using Pinia for state management, I am trying to access some state properties in the script setup section of view pages and I ...
1
vote
1
answer
45
views
Assign a method to a var?
I set an event listener when my nav is shown in show, this is via onClickOutside from VueUse.
I assign the returned method from onClickOutside to a var, calling this later turns off the event listener....
0
votes
0
answers
279
views
Making Parent Items Selectable in PrimeVue Dropdown with Groups
I'm working with PrimeVue's Dropdown component to render a hierarchical list of options grouped by country, with cities as child items. My data structure includes countries as parent labels and their ...
1
vote
1
answer
63
views
Passing object with reactive properties as a prop triggers child component onUpdated hook when updating parent component state
Consider a simple component Comp.vue file that only logs a message in the console when updated:
// Comp.vue
<script setup>
import { onUpdated } from 'vue'
onUpdated(() => {
console....
0
votes
1
answer
159
views
Vue - script does not work in <script setup> element
I have working widget from Atlassian, when I use it in html file, behaviour is as expected:
<html lang="en">
<head>
<script data-jsd-embedded data-key=<key> data-...
0
votes
1
answer
66
views
Vue 3 Composition API variable undefined after cloning it from props
I have main component that have some code and tables in it and among it it contains modal that I'm setting to visible depending on boolean.
Main component have this modal included:
<...
3
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:
...