2016-09-11 2 views
2

Discourse에서 _dock 메서드를 수정하고 싶습니다. 수정 코드는 플러그인에 배치됩니다.Ember 구성 요소의 수정 방법

export default Ember.Component.extend({ 
    elementId: 'topic-progress-wrapper', 
    classNameBindings: ['docked', 'hidden'], 

    ... 
    _dock() { 
    ... 
    }, 

}); 

방법이 방법을 수정할 :

여기에 해당 파일의 짧은 조각을입니까? 이 구성 요소를 다시 열어야하며 그 구성 요소는 무엇입니까?

답변

1

thisthis 가이드를 살펴보십시오. 당신은 새 구성 요소를 만들려면이 같은 뭔가가 필요 :

// components/my-discourse-component.js 
import MyDiscourseComponent from 'discourse/components/topic-progress'; 

MyDiscourseComponent.extend({ 
    // Here you can extend the function. Don't forget 
    // this._super(...arguments) if you want to use the original function. 
}); 

MyDiscourseComponent.reopenClass({ 
    // Here you can completly override the function. 
}); 

export default MyDiscourseComponent; 

과 당신의 temlate에 {{my-discourse-component}}를 사용합니다.

또는 애드온의 코드를 믹스 인으로 복사하고 새 믹서로 믹스를 확장하면됩니다.

+0

제 생각에는 reopenClass가 가장 적합하다고 생각합니다. 그러나 Ember Component는'elementId'에 바인드되어 있습니다. 실제 클래스 이름은 무엇입니까? – megas

+0

className, classNameBindings 및 attributeBindings는 구성 요소의 연결된 속성입니다. 따라서 classNames 또는 classNameBindings를 확장하면 addon의 모든 클래스와 구성 요소에서 정의한 클래스 이름을 가져올 수 있습니다. 이것을 참조하십시오 : http://emberjs.com/api/classes/Ember.Object.html#property_concatenatedProperties – lependu

+0

그러나 classNameBindings에는 두 개의 문자열 배열이 있습니다. 정확히 구성 요소의 이름은 무엇입니까? – megas