我正在关注reverseKey http://011.vuejs.org/api/filters.html#orderBy的文档enter link description here
这是我的代码:
<div class="one-table-row row-with-data row" v-for="message in messages | orderBy orderKey reverse |filterBy searchKey | offset offset | limit perpage">
// ...... other code
</div>
我的 View 模型:
data: function(){
return {
// other vars....
reverse: false
}
}
上面没有反转消息
列表
但是如果我使用这个:
<div class="one-table-row row-with-data row" v-for="message in messages | orderBy orderKey -1|filterBy searchKey | offset offset | limit perpage">
// ...... other code
</div>
保持 ViewModel 相同,这样就可以了。
那么为什么使用 reverse
(作为 false 或 -1)而不是 -1 内联不起作用?(它应该根据上面给出的文档链接)。
最佳答案
您链接到的文档非常旧,它适用于 Vue 0.11,您似乎使用的是较新的版本,我猜测 >= 1.0 (因为您使用的是 v-for
v-repeat
)和<2.0(因为指令中的过滤器在那之后被放弃)。
无论如何,该功能应该按照您所描述的那样工作 - 这是 working JSFiddle使用 Vue 1.0.28。请记住,true
/false
不起作用(因为您的文档链接是旧的并且不适用),您必须使用-1
/1
。
但是,如果您所描述的是真的,并且您确实也尝试过 -1
/1
,那么您的问题显然出在其他地方,因此您将不得不提供更多代码(或者更好的是,如果您希望我们提供帮助,您的问题的工作演示)。
关于javascript - Vuejs 反向键不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42610876/