반응형
Vue 2를 Vue 3으로 마이그레이션하는 중 오류:Vue는 생성자가 아닙니다.
다음 오류가 발생하여 Vue 2 구문을 Vue 3으로 마이그레이션하려면 어떻게 해야 합니까?
유형 오류:Vue는 생성자가 아닙니다.
현재 Vue 3을 사용하고 있습니다.
let app;
firebase.auth().onAuthStateChanged(user => {
console.log("user", user);
if (!app) {
app = new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
}
});
로.
import { createApp } from "vue";
const app = createApp({
});
app.mount("#app");
Vue 3, Vuex 4, Vue Router 4의 코드와 동등한 것은 다음과 같습니다.
import { createApp } from 'vue'
import store from './store'
import router from './router'
import App from './App.vue'
let app;
firebase.auth().onAuthStateChanged(user => {
console.log("user", user);
app = createApp(App);
app.use(store);
app.use(router);
app.mount("#app");
});
store.js에서는 스토어 구문이 약간 다릅니다.
import { createStore } from 'vuex'
// now uses `createStore`
export default createStore({
state: {},
getters: {},
mutations: {},
actions: {}
})
또한 router.js의 라우터:
import { createWebHistory, createRouter } from "vue-router";
import Home from "@/views/Home.vue";
import About from "@/views/About.vue";
const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/about",
name: "About",
component: About,
},
];
const router = createRouter({
history: createWebHistory(),
routes,
});
export default router;
언급URL : https://stackoverflow.com/questions/65099422/migrating-vue-2-to-vue-3-typeerror-vue-is-not-a-constructor
반응형
'programing' 카테고리의 다른 글
x86, win32의 빈 프로그램에 대한 GCC 어셈블리 출력 (0) | 2022.08.19 |
---|---|
휴지 상태를 사용하여 기본 엔티티 속성 값을 설정하는 방법 (0) | 2022.08.19 |
javadoc에서는 어떻게 @ 문자를 벗어날 수 있습니까? (0) | 2022.08.19 |
Vuex에서의 변환 유형의 실제 사용 (0) | 2022.08.19 |
무엇 현재 GCC(우분투 특히)의 기본 C-std 표준 버전일까요? (0) | 2022.08.19 |