tedirghazali / alga-js

Alga.js is javascript helper for helping build a component of any front-end web frameworks
https://algajs.tedir.dev
Other
18 stars 41 forks source link

ReferenceError: Can't find variable: $array #2

Closed tarundak closed 2 years ago

tarundak commented 3 years ago

can you help me i have this problem with vue3 + vite

I have imported import { $array, $object } from '../assets/js/alga.js'

but I am getting below error Unhandled Promise Rejection: ReferenceError: Can't find variable: $array

tedirghazali commented 3 years ago

do you use composition api on your vue3 + vite?, if yes, please avoid calling $ symbol to your setup function, so try this instead:

import { $array as useArray, $object as useObject } from '../assets/alga.min.js' (please use compress/minify js file instead)

also you can do:

import { pagination } from 'alga-js/lib/array.js'

and what a browser do you use? but it works fine for me and no error at all

CodeNinjaUG commented 1 year ago

hello am using vue 3 and laravel no vite but getting an error when i try to import

CodeNinjaUG commented 1 year ago

app.js:26405 Uncaught TypeError: (0 , alga_js_array__WEBPACK_IMPORTED_MODULE_1__.paginate)(...) is not a function am getting this error

tedirghazali commented 1 year ago

"Uncaught TypeError", I think this is because of the return value from paginate is null or nan, below this, its the code for that paginate function

const paginate = (fromArray, pageActive = 1, limitPerPage = 10) => { const newArray = Array.from(fromArray) const startPaginate = (Number(limitPerPage) Number(pageActive)) - (Number(limitPerPage) - 1) const endPaginate = Number(limitPerPage) Number(pageActive)

return newArray.slice(startPaginate - 1, (endPaginate <= newArray.length) ? endPaginate : newArray.length) }