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

商务网站设计论文广东深圳疫情最新情况

商务网站设计论文,广东深圳疫情最新情况,海南企业网站建设,南海网站建设定义 WxNotificationCenter.js 文件; /*** author: Di (微信小程序开发工程师)* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)* 垂直微信小程序开发交流社区* * github地址: https://github.com/icindy/WxNotificationCenter…

定义 WxNotificationCenter.js  文件; 

/*** author: Di (微信小程序开发工程师)* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)*               垂直微信小程序开发交流社区* * github地址: https://github.com/icindy/WxNotificationCenter* * for: 微信小程序通知广播模式类,降低小程序之间的耦合度* detail : http://weappdev.com/t/wxnotificationcenter/233*/
//   存放
var __notices = [];
var isDebug = true;
/*** addNotification* 注册通知对象方法* * 参数:* name: 注册名,一般let在公共类中* selector: 对应的通知方法,接受到通知后进行的动作* observer: 注册对象,指Page对象*/
function addNotification(name, selector, observer) {if (name && selector) {if(!observer){// ("addNotification Warning: no observer will can't remove notice");}var newNotice = {name: name,selector: selector,observer: observer};addNotices(newNotice);} else {}
}/*** 仅添加一次监听* * 参数:* name: 注册名,一般let在公共类中* selector: 对应的通知方法,接受到通知后进行的动作* observer: 注册对象,指Page对象*/
function addOnceNotification(name, selector, observer) {if (__notices.length > 0) {for (var i = 0; i < __notices.length; i++) {var notice = __notices[i];if (notice.name === name) {if (notice.observer === observer) {return;}}}}this.addNotification(name, selector, observer)
}function addNotices(newNotice) {// if (__notices.length > 0) {//     for (var i = 0; i < __notices.length; i++) {//         var hisNotice = __notices[i];//         //当名称一样时进行对比,如果不是同一个 则放入数组,否则跳出//         if (newNotice.name === hisNotice.name) {//             if (!cmp(hisNotice, newNotice)) {//                 __notices.push(newNotice);//             }//             return;//         }else{//             __notices.push(newNotice);//         }//     }// } else {// }__notices.push(newNotice);
}/*** removeNotification* 移除通知方法* * 参数:* name: 已经注册了的通知* observer: 移除的通知所在的Page对象*/function removeNotification(name,observer) {for (var i = 0; i < __notices.length; i++){var notice = __notices[i];if(notice.name === name){if(notice.observer === observer){__notices.splice(i,1);return;}}}}/*** postNotificationName* 发送通知方法* * 参数:* name: 已经注册了的通知* info: 携带的参数*/function postNotificationName(name, info) {if(__notices.length == 0){return;}for (var i = 0; i < __notices.length; i++){var notice = __notices[i];if(notice.name === name){notice.selector(info);}}}// 用于对比两个对象是否相等
function cmp(x, y) {// If both x and y are null or undefined and exactly the same  if (x === y) {return true;}// If they are not strictly equal, they both need to be Objects  if (! (x instanceof Object) || !(y instanceof Object)) {return false;}// They must have the exact same prototype chain, the closest we can do is  // test the constructor.  if (x.constructor !== y.constructor) {return false;}for (var p in x) {// Inherited properties were tested using x.constructor === y.constructor  if (x.hasOwnProperty(p)) {// Allows comparing x[ p ] and y[ p ] when set to undefined  if (!y.hasOwnProperty(p)) {return false;}// If they have the same strict value or identity then they are equal  if (x[p] === y[p]) {continue;}// Numbers, Strings, Functions, Booleans must be strictly equal  if (typeof(x[p]) !== "object") {return false;}// Objects and Arrays must be tested recursively  if (!Object.equals(x[p], y[p])) {return false;}}}for (p in y) {// allows x[ p ] to be set to undefined  if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) {return false;}}return true;
};module.exports = {addNotification: addNotification,removeNotification: removeNotification,postNotificationName: postNotificationName,addOnceNotification: addOnceNotification
}

在需要的页面js中引入该文件

var WxNotificationCenter = require("../../utils/WxNotificationCenter.js");// 广播:WxNotificationCenter.postNotificationName('广播的名字', '');    // 监听var that = this;WxNotificationCenter.addNotification('广播的名字', that.'要调用的方法' , that);

http://www.ds6.com.cn/news/35912.html

相关文章:

  • 烟台做网站多少钱如何能查到百度搜索排名
  • 网站建设开票名称个人博客网页设计
  • cms建设网站百度商业账号登录
  • asp网站时间代码站长统计app最新版本2023
  • 制作wordpress模板教程视频专业seo推广
  • 贵溪网站建设石家庄关键词排名首页
  • 基于php网站开发步骤seo优化网站的注意事项
  • 如何做网站搭建api接口西安网站制作公司
  • 企业网站建设一般考虑哪些因素?浏览器网站大全
  • 中卫市建设局网站 冯进强私域流量和裂变营销
  • 搭建博客网站中美关系最新消息
  • 在沧州盘古做苗木网站的深圳货拉拉
  • 网站建设实录西安网站建设网络推广
  • 企业网站策划大纲模板什么平台可以免费推广产品
  • 专业做外贸网站的公司照片查询百度图片搜索
  • 编程 朋友 做网站单页网站怎么优化
  • 化妆品公司网站模板成都外贸seo
  • 企云网站建设网站页面关键词优化
  • 百度 网站移动适配网站快速刷排名工具
  • 设计公司做网站有用吗google登录入口
  • 网站开发流程比较合理网络搜索关键词
  • 深圳做h5网站公司1688的网站特色
  • win系统的wordpress什么软件可以优化关键词
  • 廊坊企业做网站seo哪里有培训
  • 行业网站运营计划seo百度首页排名业务
  • 沈阳网站优化哪家好seo网站优化师
  • 灵璧做网站的公司广告推广营销网站
  • 湖北省武汉市东西湖建设局网站精准客源推广引流
  • 用墨刀做视频网站如何加入百度推广
  • 视频网站是用什么框架做的google官网注册