[Vuejs]-How to get raw html from a $refs?

3👍

You may have to wait the DOM being updated before reading it. You can use $nextTick.

watch: {
    json(val) {
        this.$nextTick().then(() => {
            console.log(this.$refs.content);
            console.log(this.$refs.content.innerHTML);
            this.rawHtml = this.$refs.content.innerHTML;
        });
    }
},

Works fine for me.

👤Sackey

Leave a comment