Load more button in vuejs

前端 未结 2 525
离开以前
离开以前 2021-02-09 23:59

I receive from php an array with customer reviews:

var comment_list = new Vue({

el: \'#comment-list\',

 data: {
    testimonials: JSON.parse(\'{!! addslashes(j         


        
2条回答
  •  旧巷少年郎
    2021-02-10 00:45

    Without an API, and loading all the comments on the initial load:

    new Vue({
      el: ".vue",
      data() {
        return {
          reviews: [{name: 'Derek', description: 'Some comment'}, {name: 'Joe', description: 'Some comment'},{name: 'Mike', description: 'Some comment'}, {name: 'Ron', description: 'Some comment'},{name: 'Dii', description: 'Some comment'}, {name: 'Lonnie', description: 'Some comment'},{name: 'Paul', description: 'Some comment'}, {name: 'Mike', description: 'Some comment'},{name: 'Jody', description: 'Some comment'}, {name: 'Ryn', description: 'Some comment'},{name: 'Jord', description: 'Some comment'}, {name: 'Milly', description: 'Some comment'},{name: 'Judy', description: 'Some comment'}, {name: 'Vanilly', description: 'Some comment'},{name: 'Nolan', description: 'Some comment'}, {name: 'Pino', description: 'Some comment'},{name: 'Ryne', description: 'Some comment'}, {name: 'Scott', description: 'Some comment'},{name: 'Son', description: 'Some comment'}, {name: 'Bann', description: 'Some comment'},],
          commentsToShow: 2
        };
      }  
    })
    
    
    {{reviews[commentIndex - 1].name}} says:
    {{reviews[commentIndex - 1].description}}

    I hope this helps!

提交回复
热议问题