[Vuejs]-How to change a Vue template without recompiling?

1👍

Short answer, yes you can edit the compiled source but this seems to be not practicable, its like reading machine code.

You can build your template several ways. Here is a link with some examples. https://vuejsdevelopers.com/2017/03/24/vue-js-component-templates/

You should maybe define your template inside your vue component.
So it will be build at runtime and you can change it, without rebuilding the entire thing.

Short example using Template Literals (“):

Vue.component('my-checkbox', {
template: `<div class="checkbox-wrapper" @click="check">
                        <div :class="{ checkbox: true, checked: checked }"></div>
                        <div class="title">{{ title }}</div>
                    </div>`,
data() {
    return { checked: false, title: 'Check me' }
},
methods: {
    check() { this.checked = !this.checked; }
}
});

Leave a comment