import { useStore }  from "vuex"
import { getCurrentInstance, computed } from "vue"

setup(){
   const store = useStore() // 获取store 实例
   const { ctx } = getCurrentInstance() // 获取当前组件实例
   console.log(ctx.$router.currentRoute.value)

  const count  = computed( () => store.state.count)  

  return {count} // 组件中 count 会随着其他的地方的 count 变化而自动相应变化
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-01-12
  • 2021-10-27
  • 2022-12-23
  • 2021-10-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案