https://github.com/davidkpiano/xstate/tree/master/packages/core#readme https://blog.jerry-hong.com/posts/xstate-tutorials-state-machine/ 安装 yarn add xstate 配合vue模拟红绿灯 <template> <div :style="`background:${state}`">{{ state }}</div> <button @click="click">click</button> </template> <script> import { createMachine, interpret } from "xstate"; import { reactive, ref } from "vue"; export default { name: "App", setup() { const states = { green: { on: { TOGGLE: "yellow" } }, yellow: { on: { TOGGLE: "red" } }, red: { on: { TOGGLE: "green" } }, }; const state = ref("green"); const toggleMachine =