I can't understand some kind of writing about preventing pages from refreshing or closing.

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;
    };
},
...
Mar.19,2021

when merging objects, the value of e is changed, the returnValue attribute is added, and custom information is created.

adding an event on a window object is a

that uses the returnValue property to create custom information.

Custom Information


Object.assign

is completely equivalent here to e.returnValue = returnValue .

is written like this, either to show off or to make the person in charge not understand
.

returnValue

is for compatibility

  

perform object merging when you are about to leave the current page (refresh or close). Maybe you will use the normalnValue value to do some logical operations in subsequent operations. At present, the code only sees the merging section, but does not see some related operations, so you can only judge that subsequent operations may be used to do some logical processing

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47bca-44c58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47bca-44c58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?