I can see such a way to prevent page refresh / close in the project. I can know what it will achieve in the end, but I can"t understand how it is written.
search the web for Object.assign ()
to find out that objects are used for merging ( example ). Why
is bound to e
here and there is no variable to receive this merge value, it is a bit incomprehensible.
also ask seniors for guidance: -)
...
mounted() {
const returnValue = "Are you sure you want to lose unsaved changes?";
window.onbeforeunload = e => {
if (!this.changedFiles.length) return undefined;
Object.assign(e, {
returnValue,
});
return returnValue;
};
},
...