exports module.exports
노출: module. exports 또는 exports 의존: require ()
인터넷 강의
module.exports
와 exports
의 글 이 특히 많 기 때문에 본문 을 쓰 는 것 은 필 기 를 하기 위해 서 이다.require () 의 반환 값 은 module. exports 입 니 다. 이 대상 은 exports 대상 을 볼 수 없습니다.
node. js 는 각 모듈 (파일) 에 다음 코드 를 추가 합 니 다.
module.exports = exports = {};
//...
exports
단지 module.exports
의 인용 일 뿐이다.부적 절 한 예 를 들 어 module.exports
회사 exports
는 프로그래머 (당신) 회사 가 너무 작 으 니 참 으 세 요.module.exports = exports = {};
exports.c = //...
exports.java = //...
exports.ruby = //...
exports.node = //...
당신 이 쓴 것 은 c, 자바, ruby 또는 node 든 모두 회사 의 회사 입 니 다. 만약 당신 이 어느 날 프로그램 을 쓰 지 않 는 다 면 회 사 는 화 를 낼 것 입 니 다. 당신 이 앞으로 프로그램 을 쓰 는 것 을 나 도 원 하지 않 습 니 다.
module.exports = exports = {};
exports.c = //...
exports.java = //...
exports.ruby = //...
exports.node = //...
exports=//...
exports.php = //...
지금 이 럴 때, 당신 이 이전에 쓴 것 은 회사 에서 도 사용 할 것 입 니 다. 당신 이 변 한 후부 터 회 사 는 당신 의 절 차 를 감히 사용 하지 못 합 니 다. 회 사 는 다른 사람 을 초빙 해 야 합 니 다.
module.exports = exports = {};
exports.c = //...
exports.java = //...
exports.ruby = //...
exports.node = //...
exports=//...
exports.php = //...
module.exports = //... , ,
그럼 우 리 는 언제
exports
를 사용 합 니까? 언제 module.exports
를 사용 합 니까?To add functions and objects to the root of your module, you can add them to the special exports object. If you want the root of your module’s export to be a function (such as a constructor) or if you want to export a complete object in one assignment instead of building it one property at a time, assign it to module.exports instead of exports.
무슨 뜻 이 죠?
만약 당신 의 모듈 이 일부 방법 과 대상 을 다른 사람 에 게 노출 시 키 기 를 원한 다 면, 이 를
exports
속성 에 추가 하 십시오. 만약 당신 의 모듈 이 구조 함수 나 완전한 대상 을 노출 시 키 기 를 원한 다 면 module.exports
결론: 네가 쓰 고 싶 은 대로 써 라. exports
에 직접 값 을 부여 하지 않 으 면 된다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Express + AWS S3 이미지 업로드하기웹 사이트 및 모바일 애플리케이션 등에서 원하는 양의 데이터를 저장하고 보호할 수 있다. 데이터에 대한 액세스를 최적화, 구조화 및 구성할 수 있는 관리 기능을 제공한다. AWS S3 에 저장된 객체에 대한 컨테이너...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.