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 1aa71a1ce2ac6a96afce38e9acb0190221897f7c..4782be1e4515283d331829f5368729a9da07677b 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)) } } })