All Questions
Tagged with vue-composition-api vue-script-setup
108 questions
105
votes
8
answers
135k
views
How to use props in <script setup> in vue3
Just like the title says,
related Links:
New script setup (without ref sugar)
<template>
<TopNavbar title="room" />
<div>
{{ no }}
</div>
</template>
...
60
votes
5
answers
147k
views
Vue Composition API: Defining emits
When defining custom events Vue encourages us to define emitted events on the component via the emits option:
app.component('custom-form', {
emits: ['inFocus', 'submit']
})
Using Vue 3's ...
57
votes
4
answers
116k
views
How can I use async/await in the Vue 3.0 setup() function using Typescript
(This question has been answered for JavaScript, see below, but this question is specific for TypeScript, which behaves differently)
I'm trying to use async functionality in Vue3.0 using typescript.
...
36
votes
2
answers
90k
views
How does Computed work in Vue 3 script setup?
I'm trying to get computed to work in <script setup>:
<template>
<div>
<p>{{ whatever.get() }}</p>
</div>
</template>
<script setup>
import {...
33
votes
4
answers
21k
views
How to use render function in <script setup> Vue3
I use Vue 3.1.1
I am using script setup in the experimental stage with single file components.
Using the script setup, I understand defineProps, defineEmit, and useContext, but I don't understand how ...
32
votes
2
answers
57k
views
Vuejs 3 emit event from child to parent component
I've recently started working with VueJS, I'm using v3 and seem to be having an issue calling a method on a parent. The emit function in the child doesn't seem to be emitting the event and nothing is ...
31
votes
4
answers
16k
views
How to define `name` and `inheritAttrs` in `<script setup>`?
Options API:
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'CustomName', // 👈
inheritAttrs: false, // 👈
setup() {
return {}
},...
30
votes
2
answers
33k
views
How to use <component :is=""> in vue 3 script setup
I am using the experimental script setup to create a learn enviroment. I got a selfmade navigation bar with open a single component.
I am having trouble using the <component :is="" /> ...
27
votes
4
answers
47k
views
How to use v-model on component in vue 3 script setup
I want to add a v-model on a component but I got this warning:
[Vue warn]: Component emitted event "input" but it is neither declared in the emits option nor as an "onInput" prop.
...
26
votes
3
answers
23k
views
Calling method on Child Component - Composition API
I have a parent component where I need to call a method that exists in one of its child components:
<template>
<div>
<button @click="callChildMethod">
<child-...
26
votes
1
answer
51k
views
Best way to get current route in Vue3 and Vue-router?
I am trying to get the current path (something like "https://example.com/some/path") with Vue3 and Vue-router.
Before, when using Vue2, I could get the current route using:
// works with ...
24
votes
3
answers
20k
views
Use props in composables vue3
I am upgrading an app from vue 2 to vue 3 and I am having some issues with composables. I'd like to use props in the composable but it doesn't seem to be working. The code sample is pulled from a ...
21
votes
5
answers
32k
views
Vue | Module has no default export
I'm facing an error with vue3, ts, vue cli where it says
Module '"c:/Users/USER/Documents/top-secret-project/src/components/Features/Features.vue"' has no default export.
when importing a ...
15
votes
1
answer
14k
views
How to access `app.config.globalProperties` in a`<script setup lang="ts">`?
how to access app.config.globalProperties withing <script setup lang="ts"> ?
I have looked around for several approaches: like this SO post, and tried to combine elements below:
\\ ...
13
votes
6
answers
26k
views
How to use Vuex mapGetters with Vue 3 SFC Script Setup syntax?
I'm refactoring component from regular Vue 3 Composition API to Script Setup syntax. Starting point:
<script lang="ts">
import { defineComponent, computed } from 'vue';
import { ...