I need to reverse the order of a JSON feed that is being used within a Vue.JS project.
In other frameworks the reverse() function has done the job. I have tried adding to the Vue.JS script but no joy yet.
Any ideas on other syntax I could try?
<script type="text/javascript">
new Vue({
el: '#vueapp',
data: {
json: null
},
created: function () {
var _this = this;
$.getJSON('https://www.example.com/myfeed.json', function (json) {
_this.json.reverse() = json;
});
}
});
</script>
So the last item in the JSON (the house on the side of the mountain in the example below), will display first when the page loads the JSON data.
https://jsfiddle.net/5kt9jurc/3/
Some Googling seems to show reverse() no longer works with Vue2 and is deprecated.