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

电子政务政府门户网站建设方案/网站关键词优化推广哪家好

电子政务政府门户网站建设方案,网站关键词优化推广哪家好,南阳网站建设培训班,网站开发 绩效考核同步加载 先使用require.register注册文件路径和对应方法之间的映射关系保存在require.modules中再使用require方法,通过传入的路径去require.modules中取出对应的方法使用require获取方法的同时,会触发依赖模块中的require方法,这样就实现了…

同步加载

  1. 先使用require.register注册文件路径和对应方法之间的映射关系保存在require.modules中
  2. 再使用require方法,通过传入的路径去require.modules中取出对应的方法
  3. 使用require获取方法的同时,会触发依赖模块中的require方法,这样就实现了模块的加载

index.html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title>
</head><body><!-- <script src="./commonJS_async.js"></script> --><script src="./commonJS.js"></script><script src="./modules/hello.js"></script><script src="./modules/name.js"></script><script>var hello = require("hello.js");console.log(hello);console.log(require.modules);// require.ensure('./modules/ajax.js', function (obj) {//     console.log(obj);// })</script>
</body>
</html>
复制代码

commonJS.js

function require(path) {let mod = require.modules[path];mod.exports = {};mod.call(window, require, mod, mod.exports);return mod.exports;
}require.modules = {};require.register = function (path, fn) {// 异步加载require.modules[path] = fn;
}
复制代码

hello.js、name.js

//hello.js
require.register('hello.js', function (require, module, exports) {let name = require('name.js')exports.hello_name = 'hello ' + name;exports.hello_world = 'hello world';
})
//name.js
require.register('name.js', function (require, module, exports) {module.exports = 'shimingw'
})
复制代码

异步加载

  1. 异步加载的逻辑匜不复杂,在同步加载的基础上增加require.ensure方法,预先在modules对象上挂在onload方法
  2. 修改require.register方法,增加异步模块注册逻辑,在异步模块注册完成后触发onload,以达到模块异步加载的需求

commonJS_async.js

function require(path) {let mod = require.modules[path].method;mod.exports = {};mod.call(window, require, mod, mod.exports);return mod.exports;
}require.modules = {};require.register = function (path, fn) {// 异步加载if (require.modules[path] && require.modules[path].status === 'loading') {// 异步加载成功require.modules[path].status = 'loaded'require.modules[path].method = fn;require.modules[path].onload(require(path));} else {require.modules[path] = {moduleName: path, // 模块Idstatus: 'loaded',onload: null,method: fn};}
}require.ensure = function (path, cb) {require.modules[path] = {moduleName: path, // 模块Idstatus: 'loading',onload: cb,method: null};var head = document.querySelector('head')var script = document.createElement('script');script.async = true;script.src = path;setTimeout(() => {head.appendChild(script);},5000 );
}
复制代码

转载于:https://juejin.im/post/5b990032e51d450e6e038d8f

http://www.lbrq.cn/news/1251073.html

相关文章:

  • 内江建网站/陕西网站建设制作
  • 网站平台怎么做的/商业公司的域名
  • 专门做招商的网站是什么意思/免费域名解析平台
  • 电商网站建设的目标/网站建设的流程及步骤
  • 如何购买网站流量/百度贴吧官网首页
  • 房产手机网站模板/电商软文范例
  • 网站套餐报价/推广产品的文案
  • 网站360全景图怎么做/怎么做电商生意
  • 泉州微信网站建设/怎么制作网站平台
  • 设计比例网站/免费的html网站
  • 深圳求职招聘网站/推广员网站
  • 建设银行吴中支行网站/山东seo多少钱
  • 北京网站优化提供商/搜索引擎优化结果
  • 找网站开发公司需要注意那几点/搜索引擎外部链接优化
  • 专业制作证件网站/google seo
  • 人防工程建设网站/google play下载
  • 跟犀牛云一样做网站的/站长之家点击进入
  • 比价 wordpress 插件下载/搜索引擎营销优化的方法
  • 如何针对你的网站做搜索优化/软文范例800字
  • 微信推广网站建设/网络广告营销经典案例
  • 本网站建设在美国/产品推广计划书怎么写
  • 海口建设/郑州seo顾问培训
  • 建设一下网站要求提供源码/国家免费培训机构
  • 建设公司宣传网站/企业qq下载
  • 闵行营销型网站制作/国色天香站长工具
  • 广州祥云平台网站建设/网络优化
  • 东阳做网站公司/seo图片优化
  • 活动设计方案模板/营销型网站优化
  • 做网站需要什么文件/深圳网站建设维护
  • 做犯法任务的网站/昆明seo建站
  • 视觉语言模型的空间推理缺陷——AI 在医学扫描中难以区分左右
  • WebView 中控制光标
  • Boosting 知识点整理:调参技巧、可解释性工具与实战案例
  • JAVA--流程控制语句
  • W3D引擎游戏开发----从入门到精通【22】
  • 力扣137:只出现一次的数字Ⅱ