Dev-FE-1 / team2-intranet-project-

토이프로젝트I - 2조 기업용 사내 인트라넷 개발
https://organic-meggy-toyproject-group2-intranet-solution-b9fd064a.koyeb.app/
0 stars 1 forks source link

컴포넌트간의 props 전달하기, 클래스 형태의 라우팅 함수 제작중 #50

Closed nakyeonko3 closed 3 months ago

nakyeonko3 commented 3 months ago

Feat: 클래스형태의 라우트 제작중

export class Route {
  constructor({ routes, routeView } = {}) {
    this.routes = routes || {};
    this.routeView = routeView || document.querySelector('route-view');
  }

  router(props) {
    let view = this.routes[location.pathname];
    if (view) {
      document.title = view.title;
      routeView.innerHTML = '';
      view.render(props);
    } else {
      history.replaceState('', '', '/');
      routeView.innerHTML = '';
      router();
    }
  }
  renderComponent(ComponentClass) {
    const componentInstance = new ComponentClass(routeView, {});
    componentInstance.render();
  }
}