[Vuejs]-How do I use the render function correctly in Vue?

0👍

The components in Vue should be inherited from vue components and injected in the base component.

Vue.component('home', {
  render(createElement) {
    return createElement("div", { class: "container" }, [
      createElement("p", { class: "my-class" }, "Some cool text")
    ])
  }
})

new Vue({
  el: '#app',
  components: ['home'],
  template: '<home/>'
})
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>

Leave a comment