问题描述
所以我创建了一个 vue 应用程序并从 vue 模块导入了 Vue 但我收到了这个错误
ERROR in src/main.ts:4:5
TS2339: Property 'use' does not exist on type 'typeof import("/data/data/com.termux/files/home/ishankbg.tech/node_modules/vue/dist/vue")'.
2 | import App from './App.vue'
3 | import { firestorePlugin } from 'vuefire';
> 4 | Vue.use(firestorePlugin);
| ^^^
5 | createApp(App).mount('#app');
6 |
我在我的 vue 应用中使用了 typescript。 我使用@vue/cli 生成了这个项目。 我想使用 vuefire 中的 firestorePlugin。
我正在使用 Vue3 这是源代码
import Vue,{ createApp } from 'vue'
import App from './App.vue'
import { firestorePlugin } from 'vuefire';
Vue.use(firestorePlugin);
createApp(App).mount('#app');
我不确定是什么导致了这个错误
解决方法
Vue 3 尚不支持
Vuefire。从主页:
注意:此版本目前支持 Vue 2 和 Firebase 7。对 Vue 3 / Composition API 和 Firebase 8 的支持正在开发中。
Vue.use
是 Vue 2 安装插件的方式。一旦 Vuefire 支持 Vue 3,请使用 app.use
而不是 Vue.use
。在 Vue 3 中,Vue
不是来自 "vue"
包的有效导出:
import { createApp } from 'vue'
import App from './App.vue'
import { firestorePlugin } from 'vuefire';
const app = createApp(App);
app.use(firestorePlugin);
app.mount("#app");