Weird effects after direct DOM manipulation #9359
-
Hi, I want to trigger the browser's file download functionality so that it presents the save as dialog. Using Firefox 88.0.1. Here's how I'm trying to do it: function download(url: string, filename: string) {
console.log(filename);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', filename);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} It works, but when I call this function, the JS console is cleared. At the top the very first message I see is the value of I guess the problem is that Quasar doesn't like messing with the DOM directly? How can I achieve equivalent functionality then? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Not just Quasar but in Vue it's bad practice to directly manipulate the DOM.
Take a look at this: |
Beta Was this translation helpful? Give feedback.
-
Check the browser support for the |
Beta Was this translation helpful? Give feedback.
@szekelyisz
Not just Quasar but in Vue it's bad practice to directly manipulate the DOM.
https://www.danvega.dev/blog/2019/04/18/tips-for-vue-developers-avoid-directly-manipulating-the-dom/
Take a look at this:
https://quasar.dev/quasar-utils/other-utils#export-file