问题
I am getting DOMException: "The operation is insecure."
error in the console from my website (using Vue). It only happens when it's hosted on github pages but it it doesn't error when it's being run locally.
Github page url: https://cubxity.github.io/ks/#/display/2227?scopes=&displayTime=true
My browser is Firefox, build id: 20181206201918
回答1:
TL;DR: This isn't a Vue issue: you cannot programmatically alter the contents of a form input through the DOM.
Input file fields are more rigorously controlled by the browser DOM codes because of decades of exploits. In this case, you are not allowed to fill in the contents of the file form automatically (programatically), the user must do it manually through the selection trigger.
This isn't a Vue thing, it is an HTML/DOM security thing to prevent scripts from triggering uploads. Someone with more knowledge can give a better answer, but I believe that is the basic issue.
Instead of trying to pre-populate the form input, I always provide a simple hyperlink to the file just below the input form to allow whatever access was intended to the existing file.
来源:https://stackoverflow.com/questions/53802391/vuejs-domexception-the-operation-is-insecure