Skip to content

useAppStoreWithOut 和 useAppStore 的区别? #1809

Answered by likui628
aimm asked this question in Q&A
Discussion options

You must be logged in to vote

https://pinia.vuejs.org/core-concepts/outside-component-usage.html
pinia可以在组件内调用,在组件外调用时你得保证pinia被激活。
这里参考了Using-the-store-outside-of-setup-的做法,将pinia的实例传入useStore

import { useStore } from '~/stores/myStore'

export default {
  asyncData({ $pinia }) {
    const store = useStore($pinia)
  },
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by likui628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants