created() { // 添加快捷键 document.addEventListener('keyup', this.handleKeyUp) }, destroyed() { // 删除快捷键 document.removeEventListener('keyup', this.handleKeyUp) }, methods: { // 添加快捷键的事件处理 handleKeyUp(e) { e.preventDefault(); e.stopPropagation(); // 点击 Delete 键 if (e.keyCode == 46) { this.deleteCurContent(); // 删除组件或模板 } } }