vuejs3

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