提交 d057df84 编写于 作者: X xiaoyucoding

fix: getImageInfo 返回 path 属性

上级 07d03bfc
import getRealPath from 'uni-platform/helpers/get-real-path'
function _getServiceAddress () {
return window.location.protocol + '//' + window.location.host
}
export function getImageInfo ({ export function getImageInfo ({
src src
}, callbackId) { }, callbackId) {
...@@ -5,11 +11,13 @@ export function getImageInfo ({ ...@@ -5,11 +11,13 @@ export function getImageInfo ({
invokeCallbackHandler: invoke invokeCallbackHandler: invoke
} = UniServiceJSBridge } = UniServiceJSBridge
const img = new Image() const img = new Image()
const realPath = getRealPath(src)
img.onload = function () { img.onload = function () {
invoke(callbackId, { invoke(callbackId, {
errMsg: 'getImageInfo:ok', errMsg: 'getImageInfo:ok',
width: img.naturalWidth, width: img.naturalWidth,
height: img.naturalHeight height: img.naturalHeight,
path: realPath.indexOf('/') === 0 ? _getServiceAddress() + realPath : realPath
}) })
} }
img.onerror = function (e) { img.onerror = function (e) {
...@@ -18,4 +26,5 @@ export function getImageInfo ({ ...@@ -18,4 +26,5 @@ export function getImageInfo ({
}) })
} }
img.src = src img.src = src
console.log(img)
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册