Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 1.15 KB

README.md

File metadata and controls

46 lines (37 loc) · 1.15 KB

JS 的撤销管理类

使用

初始化

const undoManager = new UndoManager();

实例对象属性说明

属性 类型 说明 默认值 可选值
commands Array 保存需要操作的内容 [] -
index Number 当前撤销对应的索引 -1 -
limit Number 可以撤销的最大步数 5 -
isExecuting Boolean 是否正在执行undoredo功能 false -
callback Function 执行完毕后的回调函数 - -

commands的内容如下所示

[
  {
    undo: function() {},
    redo: function() {}
  },
  ...
]

实例对象方法说明

方法名 说明 参数 返回值
add 添加需要撤销的功能 Object 实例对象
undo 触发 undo 功能 - 实例对象
redo 触发 redo 功能 - 实例对象
clear 清除 undoredo 功能 - 实例对象
execute 触发 undoredo 功能 - 实例对象

Demo

参考资料