Use Vuex 4 with Vue 2.7 - vue.js

Is there an easy way to use Vuex 4 with Vue 2.7?
In the docs for Vuex 4 it says you have to use(store) on an app instance created through createApp, but this function is not backported from Vue 3 to Vue 2.7.
I am fine with hacky solutions, since I will be using this only temporarily while I "upgrade" to Pinia

Related

How to use vue 3 with nuxt?

I'm using Nuxt3 for a project and when installing it with the cli in the docs it generated a vue 2.7 project.
How can I get to use vue 3?
If you want to use Vue3, you'll need to follow CLI's instructions for Nuxt3 located here: https://nuxt.com/docs/getting-started/introduction
If you want to use some Vue-specific packages, here you are: https://v3.nuxtjs.org/guide/directory-structure/plugins/#vue-plugins

Nuxt routing not working without using vuex persistedstate

i have nuxt js project with version 2.6 I have used persistedstate storage package in it.When i remove persistedstate than nuxt new routes are not working.

'window.Vue.use is not a function' error on a Vue2 project

I have an application running in the Azure web app, it was working well and today the website is down suddenly with an error:
window.Vue.use is not a function
The App uses Vuetify as the frontend.
Does anyone know why? Is there a quick fix?
Vue.use is from Vue 2's API, and that's now only available via an application instance in Vue 3. The error suggests your app is written with Vue 2's API, while Vue 3 is actually loaded. The timing of the error coincides with the yesterday's update to the vue package in NPM.
As of 7-FEB-2022, version 3 is the default in NPM (i.e., 3.2.30 is now the latest version), replacing Vue 2. Your app is likely pulling in vue from a CDN, and the URL is missing a version specifier (or you're using #latest):
<script src="https://unpkg.com/vue"></script> ⛔️ defaults to latest
<script src="https://unpkg.com/vue#latest"></script> ⛔️ no longer Vue 2
To ensure you're using Vue 2, include the #2 (or #2.6.14) version specifier in the URL:
<script src="https://unpkg.com/vue#2"></script>
👆
<script src="https://unpkg.com/vue#2.6.14"></script>
👆

How to install vue3 beta using vue/cli?

Right now vue3 is in beta and I want to try it.
Is there a way using #vue/cli to install the vue3 beta? if so, How?
You need the latest version of #vue/cli and then run vue add vue-next in an existing Vue CLI project.
This will:
Add Vue 3 and the new Vue 3 Compiler to your project
Configure webpack to use the new vue compiler
Install Vuex 4 and vue-router 4 beta (or alpha dunno where they are rn) if the older versions are in your project
Codemods for compatibility
More Info here
However, not every package that works with Vue2 will work with this Vue3.
If all you want to try out is the new composition-api, there is a plugin which you can add which is still using Vue2 but with many of the composition-apis Features, probably all non-breaking changes? You install that by either running
npm install #vue/composition-api
or
yarn add #vue/composition-api
and then install it like this before using other APIs:
import Vue from 'vue';
import VueCompositionApi from '#vue/composition-api';
Vue.use(VueCompositionApi);

How to import axios globally to a vue.js project [duplicate]

This question already has answers here:
use axios globally in all my components vue
(4 answers)
Closed 4 years ago.
I just installed axios to my vue project as
npm install axios
then in main.js file I import it as
import axios from "axios";
But when I use axios in my components, it says
ReferenceError: axios is not defined
that means each and every component I have to import axios.
Is there a smart way to import axios globally to my vue project.
Then I won't need to import it on components each and every time.
The power of Vue has much to do with the state management(getters, mutations and actions). Here's a good overview
I recommend you to do your axios call inside the actions, as they're executed asynchronously and you won't see your app freezing while doing your calls.