在 Vue3 中,可以通过使用 `` 组件来将 `` 组件包裹在 root div 中。以下是示例代码:

<template>
  <div id='app'>
    <teleport to='#app'>
      <keep-alive>
        <router-view />
      </keep-alive>
    </teleport>
  </div>
</template>

在这个示例中,我们使用了 `` 组件将 `` 组件传送到了 `#app` 元素中。这样,`` 组件就被包裹在了 root div 中,可以正常使用。

Vue3 中使用 root div 包裹 keep-alive 组件的技巧

原文地址: https://www.cveoy.top/t/topic/lNpD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录