vuejs-paginate icon indicating copy to clipboard operation
vuejs-paginate copied to clipboard

Working example with json data

Open oflittlemother opened this issue 6 years ago • 2 comments

Question: Is there a jsFiddle that has the component working with json data?

I can't figure out where to output my data so it correctly paginates. Thank you!

oflittlemother avatar Nov 27 '18 16:11 oflittlemother

+1

mkraha avatar Jun 21 '19 12:06 mkraha

Here is my code and replace JSONURL with urs. JS

Vue.component('paginate', VuejsPaginate)

new Vue({
	el: '#root',
	data () {
		return {
			products: [],
			pageCount: ''
		}
	},
	mounted() {
		this.fetchData();
	},

	methods: {
		fetchData() {
			axios.get('**JSONURL**')
			.then(response => {
				this.products = response.data.data,
				this.pageCount = response.data.last_page
			})
		},
		
		clickCallback: function(pageNumber) {
	    	axios.get("**JSONURL**?page="+ pageNumber)
	    	.then((response) => {
				this.products = response.data.data,
				this.pageCount = response.data.last_page
			});
	    }
	}
});

HTML

<paginate
  :page-count = "pageCount"
  :page-range="5"
  :prev-text="'Prev'"
  :next-text="'Next'"
  :container-class="'pagination'"
  :page-class="'page-item'"
  :click-handler="clickCallback">
</paginate>

mkraha avatar Jun 21 '19 13:06 mkraha