vue-composition-api

vue 3 emit warning “ Extraneous non-emits event listeners”

我的未来我决定 提交于 2021-01-27 04:16:10
问题 I am trying to emit data from child to parent using the composition API I get the following warning. [Vue warn]: Extraneous non-emits event listeners (updatedcount) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.at <HelloWorld onUpdatedcount=fn > at childcomponent.vue <template> <h1>{{ store.count }}</h1>

Vue 3 how to get information about $children

时光怂恿深爱的人放手 提交于 2021-01-23 05:02:37
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

Vue 3 how to get information about $children

大城市里の小女人 提交于 2021-01-23 04:59:29
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

Object is possibly 'null'. on a ref(null)

旧街凉风 提交于 2021-01-05 05:54:45
问题 Learning Vue Composition API (and TypeScript), from the docs I found, I should be using ref(null) to use by a sub component I have inside <template>...</template> . This subcomponent have methods like open() , and I'm accessing it like this: setup() { const subcomponentRef= ref(null); subcomponentRef.value.open(); return { subcomponentRef }; } This I agree may show the error Object is possibly 'null'. pointed to subcomponentRef.value , but the weird thing is even if I added a condition if

Object is possibly 'null'. on a ref(null)

大城市里の小女人 提交于 2021-01-05 05:51:48
问题 Learning Vue Composition API (and TypeScript), from the docs I found, I should be using ref(null) to use by a sub component I have inside <template>...</template> . This subcomponent have methods like open() , and I'm accessing it like this: setup() { const subcomponentRef= ref(null); subcomponentRef.value.open(); return { subcomponentRef }; } This I agree may show the error Object is possibly 'null'. pointed to subcomponentRef.value , but the weird thing is even if I added a condition if

Create a Global Store using Vue 3 Composition API

拥有回忆 提交于 2020-12-31 06:09:52
问题 I am trying to create a global store using only the Vue 3 Composition API. Until now I have been doing experimentation, and I read a lot how to use the Composition API, but right know I don't know how to use the provide and the inject . All I know is that the provide will have all the data that will pass to a child component, so I thought that I should import the store into the main.ts . And the code looks like this: This is the store (src/store/index.ts): import { reactive, readonly } from

Create a Global Store using Vue 3 Composition API

巧了我就是萌 提交于 2020-12-31 06:04:45
问题 I am trying to create a global store using only the Vue 3 Composition API. Until now I have been doing experimentation, and I read a lot how to use the Composition API, but right know I don't know how to use the provide and the inject . All I know is that the provide will have all the data that will pass to a child component, so I thought that I should import the store into the main.ts . And the code looks like this: This is the store (src/store/index.ts): import { reactive, readonly } from

Create a Global Store using Vue 3 Composition API

♀尐吖头ヾ 提交于 2020-12-31 06:03:42
问题 I am trying to create a global store using only the Vue 3 Composition API. Until now I have been doing experimentation, and I read a lot how to use the Composition API, but right know I don't know how to use the provide and the inject . All I know is that the provide will have all the data that will pass to a child component, so I thought that I should import the store into the main.ts . And the code looks like this: This is the store (src/store/index.ts): import { reactive, readonly } from

Props typing in Vue.js 3 with TypeScript

点点圈 提交于 2020-12-11 08:58:58
问题 I'm trying to type hint my props in a Vue 3 component, with composition API. So, I'm doing this: <script lang="ts"> import FlashInterface from '@/interfaces/FlashInterface'; import { ref } from 'vue'; import { useStore } from 'vuex'; export default { props: { message: { type: FlashInterface, required: true } }, setup(props): Record<string, unknown> { // Stuff } }; My FlashInterface looks like this: export default interface FlashInterface { level: string, message: string, id?: string } This

Props typing in Vue.js 3 with TypeScript

天大地大妈咪最大 提交于 2020-12-11 08:58:54
问题 I'm trying to type hint my props in a Vue 3 component, with composition API. So, I'm doing this: <script lang="ts"> import FlashInterface from '@/interfaces/FlashInterface'; import { ref } from 'vue'; import { useStore } from 'vuex'; export default { props: { message: { type: FlashInterface, required: true } }, setup(props): Record<string, unknown> { // Stuff } }; My FlashInterface looks like this: export default interface FlashInterface { level: string, message: string, id?: string } This