In a specific part of my application I need to get the HTML code generated by Vue and send it to my API.
The problem is: Vue adds a data-*
attribute to all HTML elements. How can I remove this attribute in all exported HTML?
console.log(this.$refs.template.$el.outerHTML)
returns:
<table data-v-2cacc920="" class="body" style="background-color: rgb(255, 255, 255); color: rgb(25, 25, 25); font-size: 14px;"><tbody><tr><td align="center" valign="top" class="float-center"><center><table align="center" class="container"><tbody><tr><td><div data-v-2cacc920="" class="columns-drop-area" style="background-color: rgb(255, 255, 255); padding: 0px;"><table data-v-2cacc920="" class="row"><tbody><tr><th data-v-2cacc920="" class="columns large-6 small-12 first"><table><tbody><tr><th><div data-v-2cacc920="" class="components-drop-area" style=""><div data-v-2cacc920="" class="item" style="border-radius: 0px; padding: 0px; font-size: 14px;"><p data-v-2cacc920="">Lorem ipsum dolor sit amet.</p></div></div></th></tr></tbody></table></th><th data-v-2cacc920="" class="columns large-6 small-12 last"><table><tbody><tr><th><div data-v-2cacc920="" class="components-drop-area"></div></th></tr></tbody></table></th></tr></tbody></table></div></td></tr></tbody></table></center></td></tr></tbody></table>
How to remove data-v-2cacc920=""
from all the HTML?
Remembering that this attribute is dynamic and it changes all the time...
I think one possibility for this is to use regex, inside a loop with all elements, but I do not understand anything about regex =/
Something like that:
this.$refs.template.$el.querySelectorAll('*')