在 Composition API 设置的上下文中 onBeforeMount 的实际用途是什么?

WoJ*_*WoJ 5 vue.js vuejs3

考虑 Vue 组件的以下部分:

<setup script lang="ts">
// place called A
const A = 1
onBeforeMount(() => {
  // place called B
  const B = 2
}
</script>
Run Code Online (Sandbox Code Playgroud)

我想了解变量创建的顺序是什么。Vue Lifecycle Hooks显示图表

在此输入图像描述

我不清楚是否(以我的例子)

  • A首先创建,然后B
  • B首先创建,然后A
  • 顺序无法保证

我相信该序列是“核心中的所有内容setup”(在我的示例中为“称为 A 的位置”),然后onBeforeMount().

onBeforeMount如果是这样,那么它的内容也可能是核心的附加值是什么setup