Vue3 - How do you provide HTML default slot content without binding it to extra markup? #18382
Unanswered
pyrello
asked this question in
Documentation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is related to this conversation: #12691. I created a separate discussion for this because I think it is a question that is more specific to Vue3 and the quirks of this specific circumstance.
Consider the following:
This will result in two stories being created. The first one will work just fine, but the second one will just display the raw HTML as text. This is related to Vue's policy on escaping strings passed through
{{ }}
. The solution to this would seem to be changing the template to the following:However, Vue doesn't recognize the
v-html
property on<template>
elements. So, your next best option is to do something like this:This will work and display the unescaped HTML as expected. But this means that your markup that gets displayed through any code examples will include the extra
<div>
element (assuming we eventually get a solution to #13917). Our intention is to use the HTML tab addon to display the HTML markup for people to use to know how to correctly construct our components if they are not using Vue. I am very much not a fan of the idea of needing to include extraneous HTML to get our examples to work.This might be solvable by using the
h()
function, but I've never used it before and I'm not clever enough to figure it out on my own yet. Any help is much appreciated.Beta Was this translation helpful? Give feedback.
All reactions