Skip to content

Commit 40db688

Browse files
committed
Release v2.2.7
1 parent 47bff8f commit 40db688

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

dist/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-virtual-scroll-list v2.2.6
2+
* vue-virtual-scroll-list v2.2.7
33
* open source under the MIT license
44
* https://github.com/tangbc/vue-virtual-scroll-list#readme
55
*/
@@ -376,7 +376,7 @@
376376
*/
377377
var VirtualProps = {
378378
dataKey: {
379-
type: String,
379+
type: [String, Function],
380380
required: true
381381
},
382382
dataSources: {
@@ -785,10 +785,9 @@
785785
this.range = this.virtual.getRange();
786786
},
787787
getUniqueIdFromDataSources: function getUniqueIdFromDataSources() {
788-
var _this2 = this;
789-
788+
var dataKey = this.dataKey;
790789
return this.dataSources.map(function (dataSource) {
791-
return dataSource[_this2.dataKey];
790+
return typeof dataKey === 'function' ? dataKey(dataSource) : dataSource[dataKey];
792791
});
793792
},
794793
// event called when each item mounted or size changed
@@ -856,15 +855,16 @@
856855
var dataSource = dataSources[index];
857856

858857
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') {
860861
slots.push(h(Item, {
861-
// key: dataSource[dataKey],
862862
props: {
863863
index: index,
864864
tag: itemTag,
865865
event: EVENT_TYPE.ITEM,
866866
horizontal: isHorizontal,
867-
uniqueKey: dataSource[dataKey],
867+
uniqueKey: uniqueKey,
868868
source: dataSource,
869869
extraProps: extraProps,
870870
component: dataComponent,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtual-scroll-list",
3-
"version": "2.2.6",
3+
"version": "2.2.7",
44
"description": "A vue component support big amount data list with high scroll performance.",
55
"main": "dist/index.js",
66
"files": [

0 commit comments

Comments
 (0)