siwadiya

Vue 的 Suspense 不能和 v-if 一起使用吗

  •  
  •   siwadiya · Nov 18, 2024 · 1576 views
    This topic created in 542 days ago, the information mentioned may be changed or developed.
    https://imgur.com/a/3tnjV7X


    首次加载的时候并没有显示 fallback 的内容,而是空白的
    3 replies    2024-11-18 20:35:16 +08:00
    v1
        1
    v1  
       Nov 18, 2024
    https://cn.vuejs.org/guide/built-ins/suspense

    不是 v-if 的问题,看下 suspense 文档
    magicflower
        2
    magicflower  
       Nov 18, 2024 via Android
    可以理解为# default 内没有异步任务,直接返回了 undefined 所以看到的是空白。
    siwadiya
        3
    siwadiya  
    OP
       Nov 18, 2024
    @kk2syc 就是说无法通过一个按钮来控制加载组件?
    像 React 这种
    ```tsx
    <Suspense fallback={<div>waiting...</div>}>{isShow && <LazyComponent />}</Suspense>
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 02:31 · PVG 10:31 · LAX 19:31 · JFK 22:31
    ♥ Do have faith in what you're doing.