File tree Expand file tree Collapse file tree 2 files changed +27
-8
lines changed
examples/dist/image-picker Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,11 @@ Component({
58
58
maxImageSize : {
59
59
type : Number ,
60
60
value : 10000000 ,
61
+ } ,
62
+ // 以对象方式传入图片链接
63
+ cells : {
64
+ type : Array ,
65
+ value : null
61
66
}
62
67
} ,
63
68
@@ -72,12 +77,19 @@ Component({
72
77
lifetimes : {
73
78
attached : function ( ) {
74
79
// 在组件实例进入页面节点树时执行
75
- const newOrOld = this . judgeNewOrOld ( ) ;
76
- this . setData ( {
77
- newOrOld
78
- } ) ;
79
- if ( newOrOld === 'old' ) {
80
- console . warn ( 'image-picker组件已经升级,建议使用最新版本,当前用法会在后续版本中暂停支持' ) ;
80
+ let newOrOld = this . judgeNewOrOld ( ) ;
81
+
82
+ // 对 cells 的兼容处理
83
+ if ( this . data . cells !== null ) {
84
+ newOrOld = 'new' ;
85
+ this . setData ( {
86
+ newOrOld,
87
+ urls : this . data . cells
88
+ } ) ;
89
+ } else {
90
+ this . setData ( {
91
+ newOrOld
92
+ } ) ;
81
93
}
82
94
} ,
83
95
} ,
@@ -110,7 +122,14 @@ Component({
110
122
let previewImageList = [ ] ;
111
123
const newOrOld = this . data . newOrOld ;
112
124
113
- if ( newOrOld === 'old' ) {
125
+ // 第一个 if 是对 cells 的兼容处理
126
+ if ( typeof ( this . data . cells ) !== 'undefined' ) {
127
+ const cells = this . data . cells ;
128
+ tempFilePath = cells [ index ] . url ;
129
+ for ( let i = 0 ; i < cells . length ; i ++ ) {
130
+ previewImageList . push ( cells [ i ] . url ) ;
131
+ }
132
+ } else if ( newOrOld === 'old' ) {
114
133
tempFilePath = this . data . urls [ index ] ;
115
134
previewImageList = this . data . urls ;
116
135
You can’t perform that action at this time.
0 commit comments