From 7c0ef6489df9b8d3df1aa5fc1e9f724e64ec0930 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 27 Oct 2021 10:57:48 +0800 Subject: [PATCH] fix(App): rich-text normlize path --- .../src/components/rich-text/nodes-parser.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/uni-components/src/components/rich-text/nodes-parser.js b/packages/uni-components/src/components/rich-text/nodes-parser.js index 1aa71a1ce2..4782be1e45 100644 --- a/packages/uni-components/src/components/rich-text/nodes-parser.js +++ b/packages/uni-components/src/components/rich-text/nodes-parser.js @@ -1,4 +1,5 @@ import { hasOwn, isPlainObject } from '@vue/shared' +import { getRealPath } from '@dcloudio/uni-platform' const TAGS = { a: '', @@ -96,6 +97,11 @@ function decodeEntities(htmlString) { ) } +function normlizeValue(tagName, name, value) { + if (tagName === 'img' && name === 'src') return getRealPath(value) + return value +} + export default function parseNodes(nodes, parentNode, scopeId) { nodes.forEach(function (node) { if (!isPlainObject(node)) { @@ -128,7 +134,7 @@ export default function parseNodes(nodes, parentNode, scopeId) { break default: if (tagAttrs.indexOf(name) !== -1) { - elem.setAttribute(name, value) + elem.setAttribute(name, normlizeValue(tagName, name, value)) } } }) -- GitLab