SHARE
TWEET

Untitled

a guest Jun 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default new Vuex.Store({
  2.     state: {
  3.         inventoryPageNumber: 0,
  4.         inventoryPageCount: 0,
  5.     },
  6.     getters: {
  7.         getinventoryPageNumber: state => {
  8.             return state.inventoryPageNumber;
  9.         },
  10.  
  11.         getinventoryPageCount: state => {
  12.             return state.inventoryPageCount;
  13.         }
  14.     },
  15.     mutations: {
  16.         setinventoryPageNumber(state, pagenumber) {
  17.             state.inventoryPageNumber = pagenumber
  18.         },
  19.  
  20.         setinventoryPageCount(state, pagecount) {
  21.             state.inventoryPageCount = pagecount
  22.         }
  23.     },
  24.     actions: {
  25.         patchinventoryPageNumber(context, pagenumber) {
  26.             context.commit('setinventoryPageNumber', pagenumber)
  27.         },
  28.  
  29.         patchinventoryPageCount(context, pagecount) {
  30.             context.commit('setinventoryPageCount', pagecount)
  31.         },
  32.  
  33.     }
  34. })
  35.      
  36. **Tempalate**
  37.       <button class="fa fa-backward fa-xs text-white button-trans" @click="firstPage" :disabled="pageNumber==0" aria-hidden="true"></button>
  38.  
  39. **Script**
  40.  
  41. computed:{
  42.    pageCount: {
  43.       get() {
  44.         let count = Math.ceil(this.products.length / this.size);
  45.         return count;
  46.       },
  47.       set(newValue) {
  48.         store.dispatch("patchinventoryPageCount", newValue);
  49.       }
  50.     }
  51. },
  52.  
  53. methods: {
  54.     firstPage() {
  55.       this.pageNumber = 0;
  56.       store.dispatch("setinventoryPageNumber", this.pageNumber);
  57.     }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top