A Pen by Sebastian Rothbucher on CodePen.
Last active
September 4, 2019 05:38
-
-
Save sebastianrothbucher/796516ac771cb23b9e5e423d2ec2a8aa to your computer and use it in GitHub Desktop.
vue-replace-static
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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