new Vue({ el: "#app", data: { html: "<div>Hello World</div>", }, computed: { output() { return this.html.replace(/[\u00A0-\u9999<>\&]/gim, (v) => '&#' + v.charCodeAt(0) + ';'); } }, methods: {}, mounted() {} })