Could not access the custom plugin in method.

fre2mansur
0
fre2mansur
commented 5 months ago

Hello,

I have created a plugin in the plugin folder paginate.js

export default (context, inject) => {
const paginate = ( totalItems,
currentPage = 1,
pageSize = 10,
maxPages = 10) => {
return "something";
}
inject('pagiante', paginate)
context.$paginate = paginate
}

I imported in nuxt-config.js
plugins: [
'@/plugins/paginate.js'
]

In my component
async asyncData({$axios, $auth, $paginate}) {
console.log($pagiante(20)) --------------------------> its working fine
},
methods: {
async search() {
console.log(this.$paginate(10)) -----------------------> not working (TypeError: _this.paginate is not a function)
}
}

what I am missing here?

0
Informations
QuestionUnresolved
#c111 - Created 5 months ago