当前位置: 首页 > news >正文

做非洲外贸的网站wordpress主主页只显示标题

做非洲外贸的网站,wordpress主主页只显示标题,肇庆cms建站系统,做羞羞的事网站1. 介绍 1.1 什么是模块化与模块 ? 将一个复杂的程序文件依据一定规则#xff08;规范#xff09;拆分成多个文件的过程称之为 模块化其中拆分出的 每个文件就是一个模块 #xff0c;模块的内部数据是私有的#xff0c;不过模块可以暴露内部数据以便其他模块使用 1.2 什…1. 介绍 1.1 什么是模块化与模块 ? 将一个复杂的程序文件依据一定规则规范拆分成多个文件的过程称之为 模块化其中拆分出的 每个文件就是一个模块 模块的内部数据是私有的不过模块可以暴露内部数据以便其他模块使用 1.2 什么是模块化项目 ? 编码时是按照模块一个一个编码的 整个项目就是一个模块化的项目 1.3 模块化好处 下面是模块化的一些好处 防止命名冲突高复用性高维护性 2. 模块暴露数据 2.1 模块初体验 可以通过下面的操作步骤快速体验模块化 创建 me.js //声明函数 function tiemo(){console.log(贴膜....); } //暴露数据 module.exports tiemo;创建 index.js //导入模块 const tiemo require(./me.js); //调用函数 tiemo();2.2 暴露数据 模块暴露数据的方式有两种 module.exports valueexports.name value 使用时有几点注意 module.exports 可以暴露 任意 数据不能使用 exports value的形式暴露数据模块内部 module 与 exports 的隐式关系exports module.exports {}require 返回的是目标模块中 module.exports 的值 2.3 暴露数据 案例 2.3.1 me.js //声明一个函数 function tiemo(){console.log(贴膜...); }//捏脚 function niejiao(){console.log(捏脚....); }//暴露数据 // module.exports { // tiemo, // niejiao // }// exports 暴露数据 // exports.niejiao niejiao; // exports.tiemo tiemo;//1. module.exports 可以暴露任意数据 // module.exports iloveyou; // module.exports 521;//2. 不能使用 exports value的形式暴露数据 // exports iloveyou // X// exports module.exports {} // console.log(module.exports); // console.log(module.exports exports);exports module.exports {tiemo:tiemo} exports.tiemo tiemo; // exports iloveyou // X 2.3.2 index.js //导入模块 const me require(./me.js);//输出 me console.log(me); // me.tiemo(); // me.niejiao();3. 导入引入模块 在模块中使用 require 传入文件路径即可引入文件 const test require(./me.js); 3.1 require 使用的一些注意事项 对于自己创建的模块导入时路径建议写 相对路径 且不能省略 ./ 和 …/js 和 json 文件导入时可以不用写后缀c/c编写的 node 扩展文件也可以不写后缀但是一般用不到如果导入其他类型的文件会以 js 文件进行处理如果导入的路径是个文件夹则会 首先 检测该文件夹下 package.json 文件中 main 属性对应的文如果存在则导入反之如果文件不存在会报错。如果 main 属性不存在或者package.json 不存在则会尝试导入文件夹下的 index.js 和index.json 如果还是没找到就会报错导入 node.js 内置模块时直接 require 模块的名字即可无需加 ./ 和 …/ 3.2 导入模块 案例 3.2.1 duanzi.js module.exports 我是个段子;3.2.2 duanzi.json {text: 有一天北极熊打电话给企鹅问他为什么每次约他去看电影他都不去为什么啊企鹅回答到我他妈太南了。,name: 曹小俊吖,id: 1 }3.2.3 index.js //导入模块 // fs // const tiemo require(./me.js);//省略后缀 JS // const tiemo require(./me);//导入 JSON 文件 // const duanzi require(./duanzi); // console.log(duanzi);//对象//导入其他类型的文件 const test require(./test);console.log(test); // //调用函数 // tiemo();3.2.4 me.js //声明一个函数 function tiemo(){console.log(贴膜...); }//暴露数据 module.exports tiemo;4. 导入模块的基本流程 require 导入 自定义模块 的基本流程 将相对路径转为绝对路径定位目标文件缓存检测读取目标文件代码包裹为一个函数并执行自执行函数。通过arguments.callee.toString()查看自执行函数缓存模块的值返回 module.exports的值 4.1 导入文件夹 案例 4.1.1 app.js module.exports 我是一个模块;4.1.2 main.js //导入 const m require(./module);console.log(m);5. CommonJS 规范 module.exports、exports以及 require这些都是 CommonJS模块化规范中的内容。 而 Node.js 是实现了 CommonJS 模块化规范二者关系有点像 JavaScript 与 ECMAScript 6. require 案例 6.1 me.js const test {name: 尚硅谷 }module.exports test;//输出 // console.log(arguments.callee.toString()); console.log(test); 6.2 show.js /*** 伪代码*/function require(file){//1. 将相对路径转为绝对路径定位目标文件let absolutePath path.resolve(__dirname, file);//2. 缓存检测if(caches[absolutePath]){return caches[absolutePath];}//3. 读取文件的代码let code fs.readFileSync(absolutePath).toString();//4. 包裹为一个函数 然后执行let module {};let exports module.exports {};(function (exports, require, module, __filename, __dirname) {const test {name: 尚硅谷}module.exports test;//输出console.log(arguments.callee.toString());})(exports, require, module, __filename, __dirname)//5. 缓存结果caches[absolutePath] module.exports;//6. 返回 module.exports 的值return module.exports; }const m require(./me.js);6.3 index.js //导入 me.js const m require(./me.js); const m2 require(./me.js);
http://www.hkea.cn/news/14316742/

相关文章:

  • 网站建设后压缩代码怎样查网站谁做的
  • 国内哪个网站用wordpress北京中国建设部网站首页
  • 湖南建设厅网站二建注销喀什市建设局网站查证件
  • 加强和改进校园网站内容建设大学生网页设计作业成品下载
  • 什么查网站是否降权网店美工分为几个级别
  • 做网站根据内容生成pdf语文建设 官方网站
  • 河北网站seowordpress首页404伪静态
  • 做网站用什么样的电脑网站名字怎样做版权
  • 百度这个网站怎么做自己怎么做视频网站
  • 贸易公司网站建设要多少钱wordpress 首页错误
  • 济南富新网站建设用织梦做视频网站
  • 深圳网站建设推广公司网页制作需要下载什么软件
  • 哪些网站做任务好赚钱的金华网站建设哪里好
  • 集团门户网站建设费用科目小程序商城推广
  • 电子商务html网站模板做视频网站公司要怎么做
  • html5网站开发教学手机商城网站方案
  • 手机开发网站工具网站首页大小
  • 婚恋网站要钱吗外贸网络营销该如何做
  • 南通影楼网站建设做外贸网站注意什么
  • 淮北网站三合一建设西安中高风险地区查询
  • 图书馆网站建设的作用wordpress栏目置顶
  • 网站诊断方法制作app用什么软件好
  • 佛山最好的网站建设公司图书馆管理系统
  • 网站的k线图怎么做网站空间的后台控制面板
  • 学校校园网站 资源建设方案wordpress主题sky
  • 合肥建设局网站首页推广型网站免费建设
  • 网站设计)精致网站赏析
  • 网站 按钮 素材如何设计一个好网站
  • 购物网站功能介绍wordpress 很卡
  • 学网站开发要多少钱wordpress 登陆白屏