diff --git a/src/core/view/components/rich-text/nodes-parser.js b/src/core/view/components/rich-text/nodes-parser.js index d94b65012dc0fb889acf2b67e6926e77da46c33f..57c2d45208e92c25ec33fcecf34137aeba70fc73 100644 --- a/src/core/view/components/rich-text/nodes-parser.js +++ b/src/core/view/components/rich-text/nodes-parser.js @@ -2,6 +2,7 @@ import { hasOwn, isPlainObject } from 'uni-shared' +import getRealPath from 'uni-platform/helpers/get-real-path' 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, $vm) { let scopeId = '' while ($vm) { @@ -134,7 +140,7 @@ export default function parseNodes (nodes, parentNode, $vm) { break default: if (tagAttrs.indexOf(name) !== -1) { - elem.setAttribute(name, value) + elem.setAttribute(name, normlizeValue(tagName, name, value)) } } })