Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling the render method in single file components using Vue

I have a Vue component which has a custom render method. The method is not getting called however.

<template>
  <div class="guide"></div>
</template>

<script>
export default {
  name: 'guide',
  render: function(createElement){
    return createElement('div', 'this will never get called?'),
  },
};
</script>

I've looked through the documentation on single file components but it makes no reference to any caveats regarding render(). Is there another way to call this method?

like image 917
devnill Avatar asked Nov 11 '16 19:11

devnill


1 Answers

As ABDEL-RHMAN suggested, removing the template will cause the code to work; the <template> causes the render method to be ignored. Working example:

<script>
export default {
  name: 'guide',
  render: function(createElement){
    return createElement('div', 'this will get called?'),
  },
};
</script>
like image 68
devnill Avatar answered Oct 15 '22 13:10

devnill