提交 805c4ebf 编写于 作者: D DCloud_LXH

fix(App): rich-text normlize path

上级 67ca9fea
...@@ -2,6 +2,7 @@ import { ...@@ -2,6 +2,7 @@ import {
hasOwn, hasOwn,
isPlainObject isPlainObject
} from 'uni-shared' } from 'uni-shared'
import getRealPath from 'uni-platform/helpers/get-real-path'
const TAGS = { const TAGS = {
a: '', a: '',
...@@ -96,6 +97,11 @@ function decodeEntities (htmlString) { ...@@ -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) { export default function parseNodes (nodes, parentNode, $vm) {
let scopeId = '' let scopeId = ''
while ($vm) { while ($vm) {
...@@ -134,7 +140,7 @@ export default function parseNodes (nodes, parentNode, $vm) { ...@@ -134,7 +140,7 @@ export default function parseNodes (nodes, parentNode, $vm) {
break break
default: default:
if (tagAttrs.indexOf(name) !== -1) { if (tagAttrs.indexOf(name) !== -1) {
elem.setAttribute(name, value) elem.setAttribute(name, normlizeValue(tagName, name, value))
} }
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册