Skip to content
代码片段 群组 项目
未验证 提交 bc0b739a 编辑于 作者: Artur Fedorov's avatar Artur Fedorov 提交者: GitLab
浏览文件

Remove Vue delete for vue 3 migration

Vue.delete is no longer supported in Vue 3
has to be replaced with common mutation
上级 696bb1c3
No related branches found
No related tags found
无相关合并请求
......@@ -2,6 +2,13 @@ import Vue from 'vue';
import * as types from './mutation_types';
import { getFileEditorOrDefault } from './utils';
const deletePropertyAndReturnNewCopy = (source, property) => {
const fileEditorsCopy = { ...source };
delete fileEditorsCopy[property];
return fileEditorsCopy;
};
export default {
[types.UPDATE_FILE_EDITOR](state, { path, data }) {
const editor = getFileEditorOrDefault(state.fileEditors, path);
......@@ -9,7 +16,7 @@ export default {
Vue.set(state.fileEditors, path, Object.assign(editor, data));
},
[types.REMOVE_FILE_EDITOR](state, path) {
Vue.delete(state.fileEditors, path);
state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path);
},
[types.RENAME_FILE_EDITOR](state, { path, newPath }) {
const existing = state.fileEditors[path];
......@@ -19,7 +26,7 @@ export default {
return;
}
Vue.delete(state.fileEditors, path);
state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path);
Vue.set(state.fileEditors, newPath, existing);
},
};
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册