Skip to content

Does Vue not support using render function in objects? #11401

Answered by LinusBorg
l-7-l asked this question in Help/Questions
Discussion options

You must be logged in to vote

Interpolations ({{ }}) are for rendering text. You can use a dynamic <component>, which accepts vnodes:

 <span>
   <component
     v-if="x.render"
     :is="x.render(x.name ? contact?.profile[x.name] : undefined)"
   />
   <template v-else>
     {{ contact?.profile[x.name] || '暂无数据' }}
   </template>
 </span>

or

<span>
 <!-- get the Text import from 'vue' -->
  <component :is="x.render ? x.render(x.name ? contact?.profile[x.name] : undefined : h(Text, contact?.profile[x.name] || '暂无数据')" />
</span>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@l-7-l
Comment options

Answer selected by l-7-l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants