当前位置:网站首页>(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 leap years between 1000 and 2000 (C language)
- VI exit exit VIM applicable novice
- 学习通否认 QQ 号被盗与其有关:已报案;iPhone 14 量产工作就绪:四款齐发;简洁优雅的软件早已是明日黄花|极客头条...
- Summary after reading how to read a Book
- STM32F1与STM32CubeIDE编程实例-超声波测距传感器驱动
- 加密市场接连爆雷,Celsius能避免破产吗?
- 每日刷题记录 (七)
- IO流总结
- Here comes the tutorial of datawhale recommendation system!
- C language printf family
猜你喜欢

UserWarning: Usage of dash-separated ‘script-dir‘ will not be supported in future versions. 笔记

Fully understand the volatile keyword

Bug description, rating and life cycle

免费送书啦!畅销书《 OpenCV图像处理入门与实践》一本全搞定

The encryption market has exploded one after another. Can Celsius avoid bankruptcy?

“AI x 科学计算”进行时,华为昇思 MindSpore 赛题火热开启,等你来!

工具箱之 IKVM.NET 项目新进展

WinForm uses zxing to generate QR code

30-year-old female, ordinary software testing Yuanyuan, confused and anxious about her career

基于STM32+RFID设计的宿舍检修管理系统
随机推荐
(JS)模仿indexOf方法寻找字符串中某个字符的位置
在Clion中使用EasyX配置
np.astype()
VI退出 退出VIM 适用新手
学习通否认 QQ 号被盗与其有关:已报案;iPhone 14 量产工作就绪:四款齐发;简洁优雅的软件早已是明日黄花|极客头条...
【NLP】文本生成专题1:基础知识
[200 opencv routines] 214 Detailed explanation of drawing ellipse parameters
全面理解Volatile关键字
flink sql cdc 并行度 会不会影响顺序呀,是不是数据同步的话一般只能设置1。
stream流(Collectors)用法
js post下载文件
QT writing IOT management platform 37- logic design
The difference between & & and &
加密市场接连爆雷,Celsius能避免破产吗?
(JS)数组去除重复
【C语言进阶】字符串和内存函数(一)
Excel日期及数字格式处理
Print leap years between 1000 and 2000 (C language)
LVGL库入门教程 - 动画
# 【OpenCV 例程200篇】214. 绘制椭圆的参数详解