vue js 组件中的原始 html(使用 nuxt)

raw html in a vue js component (with nuxt)

我在我的组件中传递的对象内部收到一个主体 (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 的正确方法?

是,使用v-html

<v-card-text v-html="actu.body"></v-card-text>

看看官方指南:https://vuejs.org/v2/guide/syntax.html#Raw-HTML

诀窍是 v-html 指令

<span v-html="rawHtml"></span>