【问题标题】:Add item to the beginning of the list [duplicate]将项目添加到列表的开头[重复]
【发布时间】:2014-12-29 01:43:50
【问题描述】:

我一直在使用以下代码在列表末尾添加新评论:

 ractive.push('BlogPosts.BlogPostId.Comments', newComment);

但是现在我需要在列表的开头添加一个项目。我查看了 ractive 文档,但没有找到合适的方法。

【问题讨论】:

    标签: javascript ractivejs


    【解决方案1】:

    使用数组的unshift方法:

    ractive.unshift('BlogPosts.BlogPostId.Comments', newComment);
    

    【讨论】:

      猜你喜欢
      • 2020-07-04
      • 1970-01-01
      • 2010-10-23
      • 2011-08-12
      • 2020-08-04
      • 1970-01-01
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多