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

标签 html vue.js nuxt.js

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

相关文章:

php - 在php中创建基于register的数据库驱动的用户主页

jquery - ajax中使用$(this)引用元素

vue.js - 将 Vue 部署到 GitHub 页面。 vue-router 出错

html - 网格右侧不需要的额外边框

html - "./"(点斜杠)html,是否会导致任何浏览器出现问题

javascript - VueJS - 如何在脚本标签中获取单个文件组件的实例

vue.js - 您正在运行Vue的esm-bundler构建。建议配置您的 bundler

vue.js - 如何在 Nuxt SSR 模式下更改页面的 URL 而无需重新加载整个页面?

javascript - 如何在选择选项中获取v-model的值

javascript - 为什么我得到,无法设置未定义的属性