当前位置:网站首页>(JS)职责链模式
(JS)职责链模式
2022-06-29 09:57:00 【不愿透露姓名的余菜鸟】
(JS)职责链模式
一步操作分为多个角色来完成
将角色分开,使用一个链串起来
class Action {
constructor(name) {
this.name = name;
this.nextAction = null;
}
setNextAction(action) {
this.nextAction = action;
}
handle() {
console.log(`${
this.name}审批`);
if (this.nextAction != null) {
this.nextAction.handle();
}
}
}
let a1 = new Action("11");
let a2 = new Action("22");
let a3 = new Action("33");
a1.setNextAction(a2);
a2.setNextAction(a3);
a1.handle();
11审批
22审批
33审批
边栏推荐
- Print prime numbers between 100 and 200 (C language)
- 【C语言进阶】通讯录实现
- Redis installation and cluster setup under Linux
- Real test = "half product + Half development"?
- Several methods of enterprise competition analysis: SWOT, Porter five forces, pest "suggestions collection"
- 由ASP.NET Core根据路径下载文件异常引发的探究
- Is it safe to open a securities account? Is it reliable?
- 历史上的今天:马斯克出生;微软推出 Office 365;蔡氏电路的发明者出生
- WinForm uses zxing to generate QR code
- 【C语言进阶】自定义类型
猜你喜欢

SQL Server 数据库的几种简单查询

FreeRTOS porting of official website based on keil5 auto configuring STM32F103 standard library

Reids设计与实现

他98年的,我玩不过他...

What happened during the MySQL installation?

全面理解Volatile关键字

QT writing IOT management platform 37- logic design

BUUCTF RE-easyre

Automatic 3D Detection and Segmentation of Head and Neck Cancer from MRI Data.

Ikvm Net project progress
随机推荐
企业竞争分析的几种方法:SWOT、波特五力、PEST「建议收藏」
dropout层
flink sql cdc 并行度 会不会影响顺序呀,是不是数据同步的话一般只能设置1。
【Rust每周一库】Tokei - 统计代码行数等信息的实用工具
全面理解Synchronized
Buuctf-- connotative software
《MongoDB入门教程》第02篇 MongoDB安装
高效工作必备:测试人如何提高沟通技能?
Memory allocation - static storage stack heap and static variable
智能组卷系统设计
8年打磨,《游戏设计梦工厂》发布史诗级更新!
BUUCTF RE-easyre
VI退出 退出VIM 适用新手
Real test = "half product + Half development"?
WinForm uses zxing to generate QR code
Several methods of enterprise competition analysis: SWOT, Porter five forces, pest "suggestions collection"
Creating postgre enterprise database by ArcGIS
Offensive and defensive world re insfsay
基于STM32+RFID设计的宿舍检修管理系统
有人遇到FlinkCdc同步MySQL时候出现的这个问题吗?