Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wk1234123
uni-app
提交
d9fc80eb
uni-app
项目概览
wk1234123
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d9fc80eb
编写于
4月 16, 2020
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 组件getRealPath过滤src空值
上级
e380df20
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
30 deletion
+30
-30
src/core/view/components/canvas/index.vue
src/core/view/components/canvas/index.vue
+25
-25
src/core/view/components/image/index.vue
src/core/view/components/image/index.vue
+3
-3
src/core/view/mixins/base.js
src/core/view/mixins/base.js
+2
-2
未找到文件。
src/core/view/components/canvas/index.vue
浏览文件 @
d9fc80eb
<
template
>
<
template
>
<uni-canvas
<uni-canvas
:canvas-id=
"canvasId"
:canvas-id=
"canvasId"
:disable-scroll=
"disableScroll"
:disable-scroll=
"disableScroll"
v-on=
"_listeners"
v-on=
"_listeners"
>
>
<canvas
<canvas
ref=
"canvas"
ref=
"canvas"
width=
"300"
width=
"300"
height=
"150"
height=
"150"
/>
/>
<div
style=
"position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;"
>
<div
style=
"position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;"
>
<slot
/>
<slot
/>
</div>
</div>
<v-uni-resize-sensor
<v-uni-resize-sensor
ref=
"sensor"
ref=
"sensor"
@
resize=
"_resize"
@
resize=
"_resize"
/>
/>
</uni-canvas>
</uni-canvas>
</
template
>
</
template
>
...
@@ -279,37 +279,37 @@ export default {
...
@@ -279,37 +279,37 @@ export default {
}
}
},
},
preloadImage
:
function
(
actions
)
{
preloadImage
:
function
(
actions
)
{
var
se
fl
=
this
var
se
lf
=
this
actions
.
forEach
(
function
(
action
)
{
actions
.
forEach
(
function
(
action
)
{
var
method
=
action
.
method
var
method
=
action
.
method
var
data
=
action
.
data
var
data
=
action
.
data
var
src
=
''
var
src
=
''
if
(
method
===
'
drawImage
'
)
{
if
(
method
===
'
drawImage
'
)
{
src
=
data
[
0
]
src
=
data
[
0
]
src
=
se
fl
.
$getRealPath
(
src
)
src
=
se
lf
.
$getRealPath
(
src
)
data
[
0
]
=
src
data
[
0
]
=
src
}
else
if
(
method
===
'
setFillStyle
'
&&
data
[
0
]
===
'
pattern
'
)
{
}
else
if
(
method
===
'
setFillStyle
'
&&
data
[
0
]
===
'
pattern
'
)
{
src
=
data
[
1
]
src
=
data
[
1
]
src
=
se
fl
.
$getRealPath
(
src
)
src
=
se
lf
.
$getRealPath
(
src
)
data
[
1
]
=
src
data
[
1
]
=
src
}
}
if
(
src
&&
!
se
fl
.
_images
[
src
])
{
if
(
src
&&
!
se
lf
.
_images
[
src
])
{
loadImage
()
loadImage
()
}
}
/**
/**
* 加载图像
* 加载图像
*/
*/
function
loadImage
()
{
function
loadImage
()
{
se
fl
.
_images
[
src
]
=
new
Image
()
se
lf
.
_images
[
src
]
=
new
Image
()
se
fl
.
_images
[
src
].
onload
=
function
()
{
se
lf
.
_images
[
src
].
onload
=
function
()
{
se
fl
.
_images
[
src
].
ready
=
true
se
lf
.
_images
[
src
].
ready
=
true
}
}
/**
/**
* 从Blob加载
* 从Blob加载
* @param {Blob} blob
* @param {Blob} blob
*/
*/
function
loadBlob
(
blob
)
{
function
loadBlob
(
blob
)
{
se
fl
.
_images
[
src
].
src
=
(
window
.
URL
||
window
.
webkitURL
).
createObjectURL
(
blob
)
se
lf
.
_images
[
src
].
src
=
(
window
.
URL
||
window
.
webkitURL
).
createObjectURL
(
blob
)
}
}
/**
/**
* 从本地文件加载
* 从本地文件加载
...
@@ -318,7 +318,7 @@ export default {
...
@@ -318,7 +318,7 @@ export default {
function
loadFile
(
path
)
{
function
loadFile
(
path
)
{
var
bitmap
=
new
plus
.
nativeObj
.
Bitmap
(
'
bitmap
'
+
Date
.
now
())
var
bitmap
=
new
plus
.
nativeObj
.
Bitmap
(
'
bitmap
'
+
Date
.
now
())
bitmap
.
load
(
path
,
function
()
{
bitmap
.
load
(
path
,
function
()
{
se
fl
.
_images
[
src
].
src
=
bitmap
.
toBase64Data
()
se
lf
.
_images
[
src
].
src
=
bitmap
.
toBase64Data
()
bitmap
.
clear
()
bitmap
.
clear
()
},
function
()
{
},
function
()
{
bitmap
.
clear
()
bitmap
.
clear
()
...
@@ -337,7 +337,7 @@ export default {
...
@@ -337,7 +337,7 @@ export default {
if
(
status
===
200
)
{
if
(
status
===
200
)
{
loadFile
(
d
.
filename
)
loadFile
(
d
.
filename
)
}
else
{
}
else
{
se
fl
.
_images
[
src
].
src
=
src
se
lf
.
_images
[
src
].
src
=
src
}
}
}).
start
()
}).
start
()
}
}
...
@@ -350,20 +350,20 @@ export default {
...
@@ -350,20 +350,20 @@ export default {
}
}
}
}
xhr
.
onerror
=
window
.
plus
?
plusDownload
:
function
()
{
xhr
.
onerror
=
window
.
plus
?
plusDownload
:
function
()
{
se
fl
.
_images
[
src
].
src
=
src
se
lf
.
_images
[
src
].
src
=
src
}
}
xhr
.
send
()
xhr
.
send
()
}
}
if
(
window
.
plus
&&
(
!
window
.
webkit
||
!
window
.
webkit
.
messageHandlers
))
{
if
(
window
.
plus
&&
(
!
window
.
webkit
||
!
window
.
webkit
.
messageHandlers
))
{
se
fl
.
_images
[
src
].
src
=
src
se
lf
.
_images
[
src
].
src
=
src
}
else
{
}
else
{
// 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin)
// 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin)
if
(
window
.
plus
&&
src
.
indexOf
(
'
http://
'
)
!==
0
&&
src
.
indexOf
(
'
https://
'
)
!==
if
(
window
.
plus
&&
src
.
indexOf
(
'
http://
'
)
!==
0
&&
src
.
indexOf
(
'
https://
'
)
!==
0
)
{
0
)
{
loadFile
(
src
)
loadFile
(
src
)
}
else
if
(
/^data:.*,.*/
.
test
(
src
))
{
}
else
if
(
/^data:.*,.*/
.
test
(
src
))
{
se
fl
.
_images
[
src
].
src
=
src
se
lf
.
_images
[
src
].
src
=
src
}
else
{
}
else
{
loadUrl
(
src
)
loadUrl
(
src
)
}
}
...
@@ -449,7 +449,7 @@ export default {
...
@@ -449,7 +449,7 @@ export default {
},
this
.
$page
.
id
)
},
this
.
$page
.
id
)
return
return
}
}
if
(
!
callbackId
)
{
if
(
!
callbackId
)
{
// fix [...]展开TypedArray在低版本手机报错的问题,使用Array.prototype.slice
// fix [...]展开TypedArray在低版本手机报错的问题,使用Array.prototype.slice
return
{
return
{
data
:
Array
.
prototype
.
slice
.
call
(
imgData
.
data
),
data
:
Array
.
prototype
.
slice
.
call
(
imgData
.
data
),
...
...
src/core/view/components/image/index.vue
浏览文件 @
d9fc80eb
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
<uni-image
v-on=
"$listeners"
>
<uni-image
v-on=
"$listeners"
>
<div
<div
ref=
"content"
ref=
"content"
:style=
"modeStyle"
:style=
"modeStyle"
/>
/>
<img
:src=
"realImagePath"
>
<img
:src=
"realImagePath"
>
<v-uni-resize-sensor
<v-uni-resize-sensor
v-if=
"mode === 'widthFix'"
v-if=
"mode === 'widthFix'"
ref=
"sensor"
ref=
"sensor"
@
resize=
"_resize"
@
resize=
"_resize"
/>
/>
</uni-image>
</uni-image>
</
template
>
</
template
>
...
@@ -43,7 +43,7 @@ export default {
...
@@ -43,7 +43,7 @@ export default {
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
},
},
realImagePath
()
{
realImagePath
()
{
return
this
.
src
&&
this
.
$getRealPath
(
this
.
src
)
return
this
.
$getRealPath
(
this
.
src
)
},
},
modeStyle
()
{
modeStyle
()
{
let
size
=
'
auto
'
let
size
=
'
auto
'
...
...
src/core/view/mixins/base.js
浏览文件 @
d9fc80eb
...
@@ -6,10 +6,10 @@ import {
...
@@ -6,10 +6,10 @@ import {
export
default
{
export
default
{
methods
:
{
methods
:
{
$getRealPath
(
src
)
{
$getRealPath
(
src
)
{
return
getRealPath
(
src
)
return
src
?
getRealPath
(
src
)
:
src
},
},
$trigger
(
name
,
$event
,
detail
)
{
$trigger
(
name
,
$event
,
detail
)
{
this
.
$emit
(
name
,
processEvent
.
call
(
this
,
name
,
$event
,
detail
,
this
.
$el
,
this
.
$el
))
this
.
$emit
(
name
,
processEvent
.
call
(
this
,
name
,
$event
,
detail
,
this
.
$el
,
this
.
$el
))
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录