전역-지역 컴포넌트 충돌시

18.10.02 12:30 작성 조회수 165

0

같은 태그에 global component와 local component를 동시에 등록하면

local만 나오는데(global은 안나옴) (충돌되지 않게 다른 태그를 입력하면 다른 게 나옴) 어떤 순서가 있는건가요?

Vue.component('todo-footer',{ template:This is another child global component`

});

var cmp = {

template: <p>This is another child local component</p>

};

var app = new Vue({

el: '#app',

data: {

message : 'This is a parent component'

},

components : {

'todo-footer': cmp

}

});`

이경우에 결과물에서

This is another child global component 는 안보이고

This is another child local component가 보입니다. (todo-footer 태그를 두 개 등록해도 동일)

답변 1

답변을 작성해보세요.

0

Daniel Ryu님의 프로필

Daniel Ryu

2019.01.17

글로벌 콤포넌트와 로컬?콤포넌트가 이름이 같다면 local로 지정한 부분이 나오는 게 맞는 것 같습니다.

왠지 순서가 Vue 객체를 인스턴스화 할 때 글로벌 콤포넌트가 먼저 씌여졌다가 이후에 components: 옵션을 사용해 정의한 로컬?콤포넌트가 글로벌 콤포넌트 위에 다시 씌여지면서 글로벌은 없어지고? 로컬 콤포넌트가 보이게 되는게 아닌가 생각해 봅니다. 자세한 건 역시 캡틴 판교님이 설명해 주시리라 믿습니다.