Skip to content

Instantly share code, notes, and snippets.

@alizhdanov
Created November 8, 2017 09:18
Show Gist options
  • Save alizhdanov/e398c06c8214a308710540cab968e2db to your computer and use it in GitHub Desktop.
Save alizhdanov/e398c06c8214a308710540cab968e2db to your computer and use it in GitHub Desktop.
Render vue components from string
// IF you need render from string in vue
// The beset example is a blog post, where your content are recieving from a server and you don't have control of it.
import Vue from 'vue';
import CustomComponent1 from './CustomComponent1.vue'
import CustomComponent2 from './CustomComponent1.vue'
export default {
props: ['res'],
components: {CustomComponent1, CustomComponent2},
render(h) {
return Vue.compile('<div>'+this.res+'</div>')
.render.apply(this, [h])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment