简体   繁体   English

JS中module.exports.run和module.exports之间的区别?

[英]difference between module.exports.run and module.exports in JS?

Title says it all. 标题说明了一切。 What is the difference between simple module.exports and module.exports.run in javascript? javascript中的simple module.exports和module.exports.run有什么区别? I really couldn't find some info on the internet. 我真的在网上找不到一些信息。 Sorry. 抱歉。

module.exports is kindof like an index of what's exported in your file. module.exports像文件中导出内容的索引。

For example, if file.js starts with the line module.exports = function(args) { , when you import file.js using const file = require("./file.js") you can access your function using file(arg1) . 例如,如果module.exports = function(args) {以行module.exports = function(args) {开头,则当您使用const file = require("./file.js")导入module.exports = function(args) {时,可以使用file(arg1) const file = require("./file.js")访问函数file(arg1)

If file.js started with the line module.exports.run = function(args) { however, if the file was imported the same way, you could only access your function using file.run() . 如果module.exports.run = function(args) {但是,如果以相同的方式导入文件,则只能使用file.run()访问函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM