diff --git a/components/markdown-viewer/markdown-viewer.vue b/components/markdown-viewer/markdown-viewer.vue
index 33b011d..16b3661 100644
--- a/components/markdown-viewer/markdown-viewer.vue
+++ b/components/markdown-viewer/markdown-viewer.vue
@@ -54,9 +54,21 @@ export default {
renderedContent() {
if (!this.content) return '';
try {
- // 添加自定义样式
- const styleTag = this.customStyle ?
- `` : '';
+ // 添加自定义样式,确保内容自动换行
+ const styleTag = ``;
// 渲染Markdown为HTML
const htmlContent = marked(this.content);
@@ -77,5 +89,25 @@ export default {
.markdown-container {
padding: 20rpx;
+ overflow-wrap: break-word;
+ word-wrap: break-word;
+ word-break: break-word;
+}
+
+/* 全局样式,确保所有元素都能自动换行 */
+.markdown-container >>> * {
+ max-width: 99% !important;
+ white-space: normal !important;
+ word-break: break-word !important;
+ overflow-wrap: break-word !important;
+}
+
+/* 特别处理代码块 */
+.markdown-container >>> pre,
+.markdown-container >>> code {
+ white-space: pre-wrap !important;
+ word-break: break-word !important;
+ overflow-wrap: break-word !important;
+ max-width: 99% !important;
}
\ No newline at end of file