vue-composition-api

How to provide/inject into Vue root instance WITH nuxt and @vue/composition-api?

北战南征 提交于 2020-08-10 04:46:34
问题 I'm trying to use @vue/apollo-composable with my Nuxt-Ts application. This is the example how it should be injected into root instance on a "normal" Vue application: import { provide } from '@vue/composition-api' import { DefaultApolloClient } from '@vue/apollo-composable' const app = new Vue({ setup () { provide(DefaultApolloClient, apolloClient) }, render: h => h(App), }) Problem: I don't know how to get access to the root instance in Nuxt-TS . I tried making a plugin, but it's injected

How to provide/inject into Vue root instance WITH nuxt and @vue/composition-api?

拥有回忆 提交于 2020-08-10 04:46:23
问题 I'm trying to use @vue/apollo-composable with my Nuxt-Ts application. This is the example how it should be injected into root instance on a "normal" Vue application: import { provide } from '@vue/composition-api' import { DefaultApolloClient } from '@vue/apollo-composable' const app = new Vue({ setup () { provide(DefaultApolloClient, apolloClient) }, render: h => h(App), }) Problem: I don't know how to get access to the root instance in Nuxt-TS . I tried making a plugin, but it's injected

How to properly reset Vue Composition Api's reactive values

大憨熊 提交于 2020-08-08 04:23:11
问题 I'm wondering how should I reset a reactive in vuejs setup? (i know if change it to the ref and using view.value will solve this problem, but there should be an answer to this for using reactive) 回答1: You can use Object.assign : setup() { const initialState = { name: "", lastName: "", email: "" }; const form = reactive({ ...initialState }); function resetForm() { Object.assign(form, initialState); } function setForm() { Object.assign(form, { name: "John", lastName: "Doe", email: "john@doe.com

Function not recognized by the new Vue Composition API

爷,独闯天下 提交于 2020-06-29 05:44:10
问题 We're trying to convert a simple SFC to use the new Vue CompositionAPI. This code works flawless: export default { data() { return { miniState: true } }, methods: { setMiniState(state) { if (this.$q.screen.width > 1023) { this.miniState = false; } else if (state !== void 0) { this.miniState = state === true } else { this.miniState = true } }, }, watch: { '$q.screen.width'() { this.setMiniState() } } }; Converting this to the new CompostionAPI looks like this: export default defineComponent({

Uncaught Error: [vue-composition-api] must call Vue.use(plugin) before using any function

和自甴很熟 提交于 2020-06-16 04:07:57
问题 Consider the following composition function: import { computed, ref } from '@vue/composition-api' import { isInternetExplorer } from 'src/services/utils/utilsService' import { Screen } from 'quasar' import { auth, getAllScopes } from 'src/services/auth/authService' const isLoginPopup = Screen.lt.sm || isInternetExplorer ? false : true const accountID = ref('') export const setAccountID = () => { const account = auth.getAccount() if (account) { accountID.value = account.idTokenClaims.oid }

Uncaught Error: [vue-composition-api] must call Vue.use(plugin) before using any function

ε祈祈猫儿з 提交于 2020-06-16 04:07:41
问题 Consider the following composition function: import { computed, ref } from '@vue/composition-api' import { isInternetExplorer } from 'src/services/utils/utilsService' import { Screen } from 'quasar' import { auth, getAllScopes } from 'src/services/auth/authService' const isLoginPopup = Screen.lt.sm || isInternetExplorer ? false : true const accountID = ref('') export const setAccountID = () => { const account = auth.getAccount() if (account) { accountID.value = account.idTokenClaims.oid }

Vue 3 composition API and access to Vue instance

女生的网名这么多〃 提交于 2020-05-15 01:00:26
问题 In main.js I have something like this: import { myUtilFunc} from './helpers'; Object.defineProperty(Vue.prototype, '$myUtilFunc', { value: myUtilFunc }); In this way I have acess to myUtilFunc across whole application with this.$myUtilFunc But how can I achieve the same in setup() method in Vue 3 if I don't have access to this ? 回答1: In Vue 3, setup has an optional second argument for context . You can access the Vue instance through context.root instead of this : setup(props, context) {

How to access root context from a composition function in Vue Composition API / Vue 3.0 + TypeScript?

可紊 提交于 2020-05-13 06:40:06
问题 I want to create a reusable wrapper function written in TypeScript for triggering a toast notification by using a composition function , as defined in the current specification for Vue 3.0: Composition API RFC. This example is using BootstrapVue v2.0 toast component. With Vue 2, it would be invoked via the this.$bvToast Vue component instance injection in the root context : this.$bvToast.toast('Error happened', { title: 'Oh no', variant: 'danger' }); This service-like composition function

How to get an vue-apollo instance with @vue/composition-api and nuxt.js

◇◆丶佛笑我妖孽 提交于 2019-12-25 01:31:44
问题 How do I configure vue-apollo ,combined with @vue/apollo-composable for consummation with @vue/composition-api or Vue3.0 ? Because although I get an default apolloClient via using @nuxtjs/apollo : import { DefaultApolloClient } from "@vue/apollo-composable"; const myPlugin: Plugin = (context, inject) => { const defaultClient = ctx.app.apolloProvider.defaultClient; // do stuff with defaultClient, e.g. provide() } export default myPlugin it's still empty instead of populated with my settings