当前位置:网站首页>Node模块化管理
Node模块化管理
2022-06-21 16:51:00 【CupidoZ】
require关键字引用其他封装好的js模块 继而实现对js文件做了模块化管理
// 引入模块化的js文件 避免引包之间存在相同引用 产生引用覆盖和调用错误
var moduleA =require('./a.js')
var moduleB =require('./b.js')
var moduleC =require('./c.js')
moduleA.test();
moduleA.to_str('abc');
moduleB();
moduleC();
// module 作为模块方法的管理方式
// 管理多个方法的时候可以将引入对象变成对象数组保存方法别名
// 两种写法
// module.exports = {
// test:test,
// to_str:to_str
// }
exports.test = test;
exports.to_str=to_str;
function test(){
console.log('test.....01')
}
function to_str(str){
return str.toUpperCase()
}
function test(){
console.log('test.....02')
}
module.exports = test
function test(){
console.log('test.....03')
}
module.exports = test
边栏推荐
- PHP输出函数
- Paper notes ACL 2022 unified structure generation for universal information extraction
- 字节跳动提出轻量级高效新型网络MoCoViT,在分类、检测等CV任务上性能优于GhostNet、MobileNetV3!
- 性能测试---locust的on_start 和 on_stop 方法
- EtherCAT igh function attempt
- 180亿,苏州诞生一个超级母基金
- PHP连接Mysql8.0报错:Illuminate\Database\QueryException
- Stack cognition - Introduction to heap
- EtherCAT igh master station controls three Delta asdaa2 servo rotating circles
- 缓存型数据库Redis的配置与优化
猜你喜欢

Postman association to complete interface automation test

Byte Jump propose un nouveau type de réseau léger et efficace, mobovit, qui surpasse GhostNet et mobilenetv3 dans la classification, la détection et d'autres tâches CV!

The way for programmers to learn

Vue.js+Node.js全栈开发教程:连接MySQL

多维分析预汇总应该怎样做才管用?

EtherCAT对象字典分析

Paper notes ACL 2022 unified structure generation for universal information extraction

企业高管收入杂谈

C语言dll动态链接库

编写第一个C#应用程序——Hello, C#
随机推荐
Paper notes ACL 2022 unified structure generation for universal information extraction
【ORACLE】Oracle里有“time”数据类型吗?--关于对Oracle数据类型的一点研究
堆栈认知——堆简介
EtherCAT igh function attempt
Lua导出为外部链接库并使用
企业高管收入杂谈
Mysql常见面试题
2022 high altitude installation, maintenance and removal work license question bank and simulated examination
EtherCAT igh 'Fatal Sync Error'——0x002C,0x001A
天天在都在谈的S3协议到底是什么?一文带你了解S3背后的故事
堆栈认知——栈溢出实例(ret2text)
Simulation of vector
Stm32f1 and stm32subeide programming example - linear Hall effect sensor driver
National administrative division
How can multidimensional analysis pre summary work?
Server socket program
Leetcode 1108 IP address invalidation [violence] the leetcode path of heroding
The source code of the online live broadcast system enables you to request the list interface and touch the bottom page to load
Vue.js+Node.js全栈开发教程:连接MySQL
研发仅占3%的蕉下,是防晒黑科技,还是夏天的智商税?