Here's a simple version of my application:
const app = Vue.createApp({ });
app.component('list', {
props: {
model: {
type: Object
}
},
template: `<div v-for="widget in model.widgets">
{{ widget.name }}
<div v-html="widget.content"></div>
<div v-html="widget.content2"></div>
<div v-html="widget.content3"></div>
</div>`
});
app.mount('#app');
I'm trying to pass the model as a property to my component, like so:
<div id="app">
<list :model="{
"widgets": [
{
"name": "Test",
"content": "<strong>Bold Text</strong>",
"content2": "<strong>Bold Text</strong>",
"content3": '<strong>Bold Text</strong>'
}
]
}"></list>
</div>
However, it doesn't display the text as bold and I'm not sure why.
Example snippet:
const app = Vue.createApp({});
app.component('list', {
props: {
model: {
type: Object
}
},
template: `<div v-for="widget in model.widgets">
{{ widget.name }}
<div v-html="widget.content"></div>
<div v-html="widget.content2"></div>
</div>`
});
app.mount('#app');
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>
<div id="app">
<list :model="{
"widgets": [
{
"name": "Test",
"content": "<strong>Bold Text</strong>",
"content2": "<strong>Bold Text</strong>"
}
]
}"></list>
</div>