html - vue.js 组件中的文本离开页面
问题描述
我正在制作“reddit 克隆”,目前我的文本没有换行,我不确定为什么当标题扩展时,它需要一个新行,但不是 for post.postMarkdown
. 这是我的模板。
<template>
<div class="home">
<div class="columns">
<div class="column is-three-quarters">
<p class="title">
{{ post.postTitle }}
</p>
<p>
<i>Posted by <a>{{ post.username }}</a></i>
</p>
</div>
<div class="column is-one-quarter right">
<b-button type="is-primary" class="back" @click="backToSubforum">Back to {{ this.$store.state.subforum }}</b-button><br />
<b-button type="is-primary" class="back" @click="backToForum">Back to forums</b-button>
</div>
</div>
<p>{{ post.postMarkdown }}</p>
<hr />
<!--
TODO: Comments
-->
</div>
</template>
解决方案
您需要使用word-wrap: break-word
, 这会破坏无空格的单词。
/* just place on global p {} */
p.word-wrap {
word-wrap: break-word
}
p.word-wrap-not {
word-wrap: unset
}
<p class="word-wrap">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p class="word-wrap-not">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
推荐阅读
- php - mySql 中创建过程的语法错误
- angular - @HostListener 无法正常工作
- c++ - 使用 VS Code 进行跨平台可扩展 C++ 项目
- cmake - 在每次增量构建之前删除 CMakeCache.txt 是否安全?
- firebase - 在没有 Cocoapods 的情况下集成 Firebase 时出现构建编译错误 [Obj-C]
- javascript - React Comlink Web Worker 阻塞 UI
- apache-nifi - 为什么不能使用 NIFI-TOOLKIT 更新 NiFi 证书颁发机构的主机名?
- sql - 两个连续日期的 SQL 窗口聚合
- mysql - MySQL - 记录所有连接、选择、更新、插入、删除和回复?
- ios - 在地图视图之上添加视图