分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

JS - 模块

发布时间:2023-09-06 02:28责任编辑:傅花花关键词:暂无标签
# CommonJS- ??[CommonJS - Wikipedia](https://en.wikipedia.org/wiki/CommonJS)## 介绍主要在浏览器之外地方(例如服务器和桌面应用上)使用的模块化技术。## 规范一个文件就是一个模块,拥有单独的作用域。## 定义模块使用 exports 或 modul.exports ???var myModul = (a, b)=>{ ???????return a+b; ???} ???module.exports = myModul;## 使用模块使用 require ???var mm = require(‘./myModul.js‘);# AMD- ??[Asynchronous module definition - Wikipedia](https://en.wikipedia.org/wiki/Asynchronous_module_definition)- ??[AMD · amdjs/amdjs-api Wiki](https://github.com/amdjs/amdjs-api/wiki/AMD)## 介绍主要在浏览器使用,因为和 CommonJS 在某些方面意见不合而独立出来(主要是模块定义方面)。## 规范一个文件就是一个模块,拥有单独的作用域。## 定义模块使用 define[amdjs-api/AMD.md at master · amdjs/amdjs-api](https://github.com/amdjs/amdjs-api/blob/master/AMD.md#using-require-and-exports)## 使用模块使用 require[require · amdjs/amdjs-api Wiki](https://github.com/amdjs/amdjs-api/wiki/require)# ES6 Modules> 现在浏览器们才刚刚开始去实现这个功能。但它在许多转换器中已经实现,例如 Traceur Compiler , Babel , Rollup 或 Webpack。这个在浏览器上用还是要转换一下的。- ??[export - JavaScript | MDN](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/export)- ??[import - JavaScript | MDN](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import)

JS - 模块

原文地址:https://www.cnblogs.com/jffun-blog/p/10206547.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved