Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
94
rated 0 times [  98] [ 4]  / answers: 1 / hits: 15436  / 7 Years ago, sun, january 29, 2017, 12:00:00

i have created Vuejs app using vue-loader,now i need to use an installed npm package as follow :





   var x = require('package-name')
Vue.use(x)





but i have this error :



Uncaught TypeError: plugin.apply is not a function


dose Vuejs require a special type packages or it can work with any JavaScript package and this error can be solved


More From » vue.js

 Answers
18

Plugins are specific Vue packages that add global-level functionality to Vue, so if you aren't using a Vue plugin then you don't need to register it with Vue using Vue.use().


In general there isn't any issue using non-vue-specific packages via npm but if you need to register something globally, you can usually get away with simply attaching it to window like so:


window.x = require('package-name');

[#59166] Thursday, January 26, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josuea

Total Points: 609
Total Questions: 121
Total Answers: 104

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;