토요일.

main.js에 구축했던 Google Login모듈을 리팩토링 하려고, google.service.js를 하나 만든것 까지는 좋았는데.

app.use(‘xx’)를 사용 할 수가 없었다.

알아야 하는 사항들

  • main.js에서 만든 createApp()은 인스턴스를 생성한다.
  • getCurrentInstance()를 사용해서 다른 모듈에서 접근이 가능하다.
  • app을 끄집어 내기 위해서는 appContext를 사용해야 한다.
import { getCurrentInstance } from "vue";
function xx() {
  const instance = getCurrentInstance();

  // app에 접근해서 plugin을 주입한다.
  instance.appContext.app.use(PluginObject, PluginOption);
}

Read Count