Vue 3:Vue.createApp 不是构造函数

Vue 3: Vue.createApp is not a constructor

我是 Vue 的新手,正在努力学习如何使用它。

我想我在尝试安装一个新的 Vue 应用程序时被绊倒了。

以下是我可以开始工作的内容:

<script src="https://unpkg.com/vue"></script>
<script>
const vm = new Vue({})
</script>

从那里我可以安装它并正确使用所有东西。

但是,这当前加载了旧版本的 Vue (2.6.7)

我想学习最新版本 (Vue 3),所以我尝试导入包 recommended by Vue docs:

<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = new Vue({})
</script>

我在控制台中收到以下错误:

Uncaught TypeError: Vue is not a constructor

我也尝试模仿 Vue 3's docs 的语法。

<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = new Vue.createApp({})
</script>

但它抛出同样的错误:

Uncaught TypeError: Vue.createApp is not a constructor

使用不同的 CDN 或特定版本 (vue@3.0.2) 也得到相同的结果。

我做错了什么?

createApp 不是一个对象它是一个函数 returns vue app 的一个实例,所以它应该是:

 const vm = Vue.createApp({}) //remove the new

createApp
Returns an application instance which provides an application context. The entire component tree mounted by the application instance share the same context
const app = Vue.createApp({})