Create text node with custom render function in Vue.js

后端 未结 5 1505
栀梦
栀梦 2021-02-13 02:26

I\'m using a my-link component to wrap an anchor tag on demand around various items. For that purpose a custom render method is used - however the

5条回答
  •  攒了一身酷
    2021-02-13 03:00

    You need a root element for a component. In your case, maybe you can use 'h4' as the root element since I see you include that anyway in the v-for loop. Once you have done that, you can then create a text node like this.

    return createElement(
        'h3',
        {},
        ['Plain text item']
    );
    

    According to Vue documentation, the third argument of createElement could be string or array, if it is a string it will be converted to text node.

    https://vuejs.org/v2/guide/render-function.html#createElement-Arguments

提交回复
热议问题