0

我正在我的 app.svelte 中使用 xstate 开发一个苗条的项目我有这个代码 =

  <script>
  import { Machine } from 'xstate'
  import { useMachine } from 'xstate-svelte';
  

  enum STATE {
        LOADING = 'LOADING',
        LOGIN   = 'LOGIN',
        PLATFORM= 'PLATFORM',
    }
    enum EVENT {
        NEEDING_TO_LOG  = 'NEEDING_TO_LOG',
        LOGGINGIN       = 'LOGGINGIN',
        LOGGINGOUT      = 'LOGGINGOUT',
    }
    const machine = Machine({
        id      : 'pages',
        initial : STATE.LOADING,
        states  : {
            [STATE.LOADING] : {
                on : {
                    [EVENT.LOGGINGIN] : STATE.PLATFORM,
                    [EVENT.NEEDING_TO_LOG] : STATE.LOGIN,
                }
            },
            [STATE.LOGIN] : {
                on : {
                    [EVENT.LOGGINGIN] : STATE.PLATFORM,
                }
            },
            [STATE.PLATFORM] : {
                on : {
                    [EVENT.LOGGINGOUT] : STATE.LOGIN,
                }
            },
        },
    });
    const { state, send } = useMachine(machine);
    function sendFsm(event: EVENT): void {
        send(event);
    }




</script>

<main>
    <h1>H1</h1>
    
    <h1>Hello {JSON.stringify(state)}!</h1>
    <button on:click={ () => sendFsm(EVENT.LOGGINGIN)}>Login</button>
    <button on:click={ () => sendFsm(EVENT.LOGGINGOUT)}>Logout</button>
    
</main>

在执行 npm run dev 时,出现此错误

node_modules/xstate/es/scheduler.js (27:11) 25: } 26: 27: this.process(callback); ^ 28: } 错误:在 Module.error (/home/ matias93/Escritorio/proyecto-2.0/plataforma-web/node_modules/rollup/dist/shared/rollup.js:9820:16)

4

0 回答 0