-
// Need to be used outside the setup useAppStoreWithOut 内部也是调用一下 useAppStore,那在外界调用 useAppStoreWithOut 和 直接调用 useAppStore 有什么区别啊 |
Beta Was this translation helpful? Give feedback.
Answered by
likui628
Aug 25, 2023
Replies: 2 comments
-
我也想知道为什么 |
Beta Was this translation helpful? Give feedback.
0 replies
-
https://pinia.vuejs.org/core-concepts/outside-component-usage.html import { useStore } from '~/stores/myStore'
export default {
asyncData({ $pinia }) {
const store = useStore($pinia)
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
likui628
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pinia.vuejs.org/core-concepts/outside-component-usage.html
pinia可以在组件内调用,在组件外调用时你得保证pinia被激活。
这里参考了Using-the-store-outside-of-setup-的做法,将pinia的实例传入useStore