web123456

vue3 uses vuex related methods in setup

<template> <div> <h2>{{ $ }}</h2> <button @click="plusCount">Click</button> </div> </template> <script> import { useStore } from "vuex"; export default { setup(props, context) { const store = useStore(); // Use the useStore method console.log(store); function plusCount() { store.commit("increaseCount"); } return { plusCount }; }, }; </script>