We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
v-for="(person, index) in people" 这个应该为 v-for="(index,person) in people" 吧。 索引在前,元素在后。
The text was updated successfully, but these errors were encountered:
这个不一定的吧?你看jquery里面function里面2种都是有的啊。
Sorry, something went wrong.
@wangmaojiawan 这个还真的就是一定的,但是(index,person) in people这种索引在前,元素在后是vue1.x的写法。到了vue2.0,就换成了(person,index) in people这种元素在前,索引在后的写法了。 现在如果你使用vue2.0,还是索引在前元素在后,会出错 详见Vue官方文档(从Vue1.x迁移): http://cn.vuejs.org/v2/guide/migration.html#v-for-遍历数组时的参数顺序-变更
@wangmaojiawan 对了.. 也顺便说一下,其实官方文档里面也有写,Vue2.0之所以这么改,是因为想跟原生JS的forEach方法保持一致(元素在前,索引在后)
@BunnyWithYou 但是现在用原生都JS的forEach方法都少了,一般都会用jQuery的Each方法了吧,我还觉得保持和jQuery的一致好一些。
No branches or pull requests
v-for="(person, index) in people"
这个应该为
v-for="(index,person) in people"
吧。
索引在前,元素在后。
The text was updated successfully, but these errors were encountered: