How to access the index of an item in knockout.js template

前端 未结 3 1245
悲哀的现实
悲哀的现实 2021-02-05 11:17

Within my template in tbody below, how can I access the index of the item being rendered?

3条回答
  •  感情败类
    2021-02-05 11:28

    I believe it gets easier with KO 2.1: you can use $index in the foreach loop to refer to the current index.

    https://github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js

    documentation: http://knockoutjs.com/documentation/binding-context.html

提交回复
热议问题