-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add useStore for v3 for vue 2.7 with composition api #2212
Comments
https://blog.csdn.net/qq_16139383/article/details/119935755 |
@ThomasKientz Did you find a workaround? |
@dgautsch no |
I need the hook too. |
You can create your own useStore, // utils file
import {getCurrentInstance} from 'vue'
export const useStore = () => {
const vm = getCurrentInstance();
if (!vm) throw new Error('must be called in setup');
return vm.proxy.$store;
}; You can use it anywhere you want: import { useStore } from '@/utils/index';
const store = useStore(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this feature solve?
Vue 2.7 supports composition API but we can't use it with Vuex (v3).
What does the proposed API look like?
Porting
useStore
from v4 to v3. Or make v4 compatible with vue 2.7.The text was updated successfully, but these errors were encountered: