0

I got this code: https://codepen.io/nuzze/pen/XWryNNY

What I want is that when you click on "Sort by Rate" the items are sorted by rate.

This is the app.js:

const app = new Vue ({
     el: '#app',
     data: function(){
        return {
          complejos: [
          {
           name: 'nice',
           rate: '3.8'
          },
          {
           name: 'cool',
           rate: '3.9'
          },
          {
           name: 'beauty',
           rate: '4.1'
          }
         ]
        }
    }});`
Dharman
  • 26,923
  • 21
  • 73
  • 125
NuzzeSicK
  • 459
  • 1
  • 4
  • 16
  • https://vuejs.org/v2/guide/list.html#Displaying-Filtered-Sorted-Results https://vuejs.org/v2/guide/events.html#Listening-to-Events Relevant. Also, you need to cast your rates as floats, not strings. – Orpheus Sep 19 '19 at 18:05
  • can you make a pen? – NuzzeSicK Sep 19 '19 at 18:23
  • 1
    I would have added this as an answer if it hadn't been marked as a duplicate prematurely... After looking at your CodePen, the issue is that your buttons are outside of your `app` div. Vue doesn't know about anything that lives outside of the element it is bound to. Move your buttons inside the div, then attach an event listener to the "sort by rate" button. See my fiddle here: https://jsfiddle.net/ht68fnvk/ – Vince Sep 19 '19 at 18:56

0 Answers0