Calling a rendering method on individual file components using Vue

I have a Vue component that has its own rendering method. However, the method is not called.

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

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

I looked at the documentation for the components of a single file, but does not refer to any caveats regarding render (). Is there any other way to call this method?

+4
source share
1 answer

As suggested by ABDEL-RHMAN, deleting the template will cause the code to work; <template>causes ignoring the rendering method. Working example:

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

Source: https://habr.com/ru/post/1660541/


All Articles