Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Last active September 4, 2019 05:38
Show Gist options
  • Save sebastianrothbucher/796516ac771cb23b9e5e423d2ec2a8aa to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/796516ac771cb23b9e5e423d2ec2a8aa to your computer and use it in GitHub Desktop.
vue-replace-static
<div id="rootDiv">
<div v-if="!loaded">Content from Server</div>
<test-comp v-if="loaded"></test-comp><!-- do NOT shorthand, vue does swallow the rest of rootDiv then -->
<test-bt><button>from Server</button></test-bt>
<div v-text="vueText">Text from Server</div>
</div>
<br /><br />
<button onclick="igniteVue()">Go, vue!</button> (normally on load)
Vue.component('TestComp', {
template: '<div style="font-weight: bold; ">Content from Vue</div>',
});
Vue.component('TestBt', {
template: '<button>from Vue</button>',
});
function igniteVue() {
new Vue({
el: '#rootDiv',
data: {
loaded: true,
vueText: 'Text vom Vue',
},
});
Vue.$forceUpdate();
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment