Vue3 檔案的這一部分說,應該可以component對createApp.
我創建使用專案VUE-CLI帶vue create myApp。
我選擇了 Vue3 并在專案中添加了 typescript。
生成的專案包含一個名為main.tswhere createAppis used的檔案。
我嘗試使用component檔案中指示的方法并收到以下錯誤。
ERROR in src/main.ts:6:5
TS2339: Property 'component' does not exist on type 'ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>'.
// main.ts
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App).mount('#app')
app.component("er", {})
是否需要進行更多設定才能使用 Vue 的所有功能?
uj5u.com熱心網友回復:
createApp(App)并且createApp(App).mount('#app')是不同的物件。前者是Vue實體,后者是組件實體。
它應該是:
const app = createApp(App)
app.component("er", {})
const vm = app.mount('#app')
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/395504.html
