Create text node with custom render function in Vue.js

后端 未结 5 1603
栀梦
栀梦 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:03

    It's actually very simple to do this without needing to use any private methods.

    A VNode which just renders text has all properties undefined, expect for text.

    So you can just

    return { text: 'my text' };
    

    If you're using TypeScript, you may need to assert it is a VNode.

提交回复
热议问题