我在我的组件中传递的对象内部收到一个主体(actu.body),里面有 html 标签(主要是 p 标签),我想知道如何为客户端解释它们,我的代码现在是这样的:
<template>
<div>
<!-- {{ actu }} -->
<v-parallax
:src="actu.images[0].url"
dark
>
<v-layout
align-center
column
justify-center
>
<h1 class="display-2 font-weight-thin mb-3">{{ actu.headline }}</h1>
<h4 class="subheading">{{ actu.summarry }}</h4>
</v-layout>
</v-parallax>
<v-card>
<v-card-text>
{{ actu.body }}
</v-card-text>
</v-card>
</div>
</template>
<script>
export default {
props: {
actu: {
type: Object,
required: true
}
} };
是否有使用 vue js 的正确方法?
最佳答案
看看官方指南:https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML
诀窍是 v-html 指令
<span v-html="rawHtml"></span>
关于html - vue js 组件中的原始 html(使用 nuxt),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51542239/