Evan You 10 лет назад
Родитель
Сommit
68372ea26b
2 измененных файлов с 2 добавлено и 4 удалено
  1. 1 3
      src/compiler/parser/index.js
  2. 1 1
      test/unit/features/directives/for.spec.js

+ 1 - 3
src/compiler/parser/index.js

@@ -216,9 +216,7 @@ function processFor (el) {
       el.alias = alias
     }
     if ((exp = getAndRemoveAttr(el, 'track-by'))) {
-      el.key = exp === '$index'
-        ? exp
-        : el.alias + '["' + exp + '"]'
+      el.key = exp
     }
   }
 }

+ 1 - 1
test/unit/features/directives/for.spec.js

@@ -295,7 +295,7 @@ describe('Directive v-for', () => {
           { id: 3, msg: 'c' }
         ]
       },
-      template: '<div><div v-for="item in items" track-by="id">{{ item.msg }}</div></div>'
+      template: '<div><div v-for="item in items" track-by="item.id">{{ item.msg }}</div></div>'
     })
     vm.$mount()
     expect(vm.$el.textContent).toBe('abc')