잘못된 생각 일 수도 있으니, 제 생각을 자유롭게 고쳐주세요.
나는 simpleSchema를 사용하고 있고 하나 이상의 스키마에서 사용되는 코드 섹션이 있습니다. 개별 구성 요소를 만들고 각 스키마로 가져 오는 방법이 있습니까? 그러면 구성 요소를 업데이트해야 할 때 여러 위치에서 업데이트 할 필요가 없습니다.
통로: resuableComponent
type: String,
optional: true,
autoform: {
type: "select",
options: function () {
return [
{label: "School logo 1", value: 'url'},
{label: "School logo 2", value: 'url'},
{label: "School logo 3", value: 'url'},
];
},
}
통로: studentCollection.js
Schemas.Student = new SimpleSchema({
studentUserId: {
type: String,
},
school: {
type: String,
optional: false
},
**resuableComponent**
});
통로: teacherCollection.js
Schemas.Teacher = new SimpleSchema({
teacherUserId: {
type: String,
},
school: {
type: String,
optional: false
},
**resuableComponent**
});
SimpleSchema를 사용하는 경우 재사용 가능한 개체를 클라이언트와 서버 모두에서 볼 수있는 다른 파일로 이동할 수 있습니다.
질문에 근거한 예 :
lib/schema-components.js
:
SchemaComponents = {
school: {
type: String,
optional: false
},
// ...
// more reusable components here
};
someCollectionFile.js
:
Schemas.Student = new SimpleSchema({
studentUserId: {
type: String
},
school: SchemaComponents.school,
// ...
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다