首页 > 解决方案 > 如何获取 — 插值时显示为破折号

问题描述

在我正在处理的页面上,我试图将博客文章的标题读取为,其中和Sleep—It's frustratingly Important.之间有一个破折号。以前我有这个硬编码为SleepIt's

<h2 class="post-title"><router-link to="/posts/1">Sleep&#8212It's frustratingly Important. </router-link></h2>

这工作正常。我想概括这一点,所以在我的 Rails 后端我将帖子标题存储为Sleep&#8212It's frustratingly Important.. 但是当我通过插值插入帖子标题时

<h2 class="post-title"><router-link to="/posts/1"> {{ this.posts[0].title }} </router-link></h2>

它不会插入破折号。它显示为“睡眠—It's frustratingly Important”。

为什么 html 不能识别 — 应该更改为破折号?我该如何解决这个问题?

标签: vue.js

解决方案



推荐阅读