vuejs3

How to use Vue.prototype or global variable in Vue 3?

不问归期 提交于 2021-01-20 04:47:13
问题 Like the title, I want to add Axios into Vue prototype. So when I want to use it, I can use it like this.$axios instead of importing it every time. CODE: //plugins/axios.ts import axios from 'axios' import router from '../router/index' const errorHandle = (): void => {}; const instance = axios.create({ // baseURL: process.env.NODE_ENV == 'development' ? '' : '' baseURL: 'http://localhost:3000', timeout: 1000 * 12 }); instance.defaults.headers.post['Content-Type'] = 'application/x-www-form

Vuejs 3: Problem with vue-template-compiler

一曲冷凌霜 提交于 2021-01-13 08:57:10
问题 I am trying to integrate vuejs 3 to an existing project which uses webpack. I read about vue-loader, so I am trying to use it. In the official documentation I have this: Every time a new version of vue is released, a corresponding version of vue-template-compiler is released together. The compiler's version must be in sync with the base vue package so that vue-loader produces code that is compatible with the runtime. This means every time you upgrade vue in your project, you should upgrade

Question about Vue 3 + TypeScript and Augmenting-Types-for-Use-with-Plugins

戏子无情 提交于 2021-01-01 04:14:29
问题 Does anyone know of a working example of how the type augmentation should be implemented with Vue3 and TypeScript? I have been trying follow the Vue2 docs in hoops of using the same in Vue3 with no success and spend the past 3 hours of searching without any results. It seems that the Vue object in the vue-class-component module should be augmented to work,but how? My implementation is similar to the following: Any advice? https://vuejs.org/v2/guide/typescript.html#Augmenting-Types-for-Use

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

VueJS/Typescript - Cannot find module './components/Navigation' or its corresponding type declarations

你。 提交于 2020-12-26 07:58:47
问题 When I create a script as typescript (lang="ts") I get an error stating "Cannot find module './components/Navigation' or its corresponding type declarations (Vetur 2307).". I realized that this only happens when I set the lang as ts, which is what I need to build my Vue application. app.vue <template> <Navigation /> </template> <script lang="ts"> import Navigation from './components/Navigation'; // This is where I get the error message export default { name: 'app', components: { Navigation, }

Can Vue2 components be used in Vue3

一曲冷凌霜 提交于 2020-12-12 06:08:09
问题 I've currently got a library of Vue2 components I've created and use in several projects via a private npm repo. I'm starting a new project now in Vue3 but I'd like to use the old components if possible. Can I mix versions like that? Also, can components be mixed the opposite way (Vue3 components in Vue2 apps)? 回答1: Vue2 components can be used with Vue3 and Vue3 components can be used in Vue2. HOWEVER... As long as you use Classic Vue Js class-based API you should have no issues. Even though

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