vue-hot-reload-api icon indicating copy to clipboard operation
vue-hot-reload-api copied to clipboard

HMR with inline-template bindings doesn't seem to work

Open ghost opened this issue 8 years ago • 0 comments
trafficstars

Sample code:

export const foo = {
    template: "",

    data: () => ({
        visible: false
    }),

    methods: {
        toggle: function() { 
            this.visible = !this.visible; 
        }
    }
};
<foo inline-template>
    <div>
        <button v-on:click="toggle"></button> 
        <div v-bind:class="{visible: visible}">
            bar
        </div>
    </div>
</foo>
import { foo } from "./foo";

if (module.hot) {
    const api = require("vue-hot-reload-api");

    api.install(Vue);

    if(!module.hot.data) {
        api.createRecord("foo-id", foo);
    } else {
        api.reload("foo-id", foo);
    }

    module.hot.accept();
}

const app = new Vue({
    el: "#app",

    components: {
        "foo": foo
    }
});

After a hot reload the HTML bindings seem to be lost. The html is served from a server and bound on the client. Is there a way to make that work with hot reloading? I'm trying out a progressive enhancement approach.

Thank you in advance!

ghost avatar Dec 27 '16 10:12 ghost