File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
1
/*!
2
- * vue-virtual-scroll-list v2.2.6
2
+ * vue-virtual-scroll-list v2.2.7
3
3
* open source under the MIT license
4
4
* https://github.com/tangbc/vue-virtual-scroll-list#readme
5
5
*/
376
376
*/
377
377
var VirtualProps = {
378
378
dataKey : {
379
- type : String ,
379
+ type : [ String , Function ] ,
380
380
required : true
381
381
} ,
382
382
dataSources : {
785
785
this . range = this . virtual . getRange ( ) ;
786
786
} ,
787
787
getUniqueIdFromDataSources : function getUniqueIdFromDataSources ( ) {
788
- var _this2 = this ;
789
-
788
+ var dataKey = this . dataKey ;
790
789
return this . dataSources . map ( function ( dataSource ) {
791
- return dataSource [ _this2 . dataKey ] ;
790
+ return typeof dataKey === 'function' ? dataKey ( dataSource ) : dataSource [ dataKey ] ;
792
791
} ) ;
793
792
} ,
794
793
// event called when each item mounted or size changed
856
855
var dataSource = dataSources [ index ] ;
857
856
858
857
if ( dataSource ) {
859
- if ( Object . prototype . hasOwnProperty . call ( dataSource , dataKey ) ) {
858
+ var uniqueKey = typeof dataKey === 'function' ? dataKey ( dataSource ) : dataSource [ dataKey ] ;
859
+
860
+ if ( typeof uniqueKey === 'string' || typeof uniqueKey === 'number' ) {
860
861
slots . push ( h ( Item , {
861
- // key: dataSource[dataKey],
862
862
props : {
863
863
index : index ,
864
864
tag : itemTag ,
865
865
event : EVENT_TYPE . ITEM ,
866
866
horizontal : isHorizontal ,
867
- uniqueKey : dataSource [ dataKey ] ,
867
+ uniqueKey : uniqueKey ,
868
868
source : dataSource ,
869
869
extraProps : extraProps ,
870
870
component : dataComponent ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vue-virtual-scroll-list" ,
3
- "version" : " 2.2.6 " ,
3
+ "version" : " 2.2.7 " ,
4
4
"description" : " A vue component support big amount data list with high scroll performance." ,
5
5
"main" : " dist/index.js" ,
6
6
"files" : [
You can’t perform that action at this time.
0 commit comments