Skip to content

Could you provide an example to create a render function in runtime? #15

Answered by huang-julien
shtse8 asked this question in Q&A
Discussion options

You must be logged in to vote

no i mean it's better to use

h({
  template: "<div></div>" <-- this
})

ssrCompile will compile the template then cache it.

using compile from vue

import { compile } from "vue"

{
  render: compile( "<div></div>" )
}

make the server-renderer compile your template each time it need to render the component.

Thanks for the module. It saves me a lot!

Currently, I am using the following code to create render function but not sure if it is the proper way.

// DynamicComponent.vue
<script setup lang="ts">
import type { Component } from '@vue/runtime-core'
import { NuxtLink, SmartImage } from '#components'

const props = defineProps<{
  content?: string
}>()

const renderer = computed(() => () => …

Replies: 9 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@msoler75
Comment options

Answer selected by shtse8
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #11 on August 01, 2022 14:54.