How to import a script into a vue.js component?

Home / Uncategorized / How to import a script into a vue.js component?

I’ve purchased a plugin called filePicker that I want to use in one of my vue.js components.

The plugin author shows only the usual way to import the js scripts at the end of the element like so:

In my component, I did the following:

The first import filepicker.js works but with the 2nd (filepicker-drop) I get the following error when I try to compile

ERROR Failed to compile with 1 errors

This dependency was not found: * fs in ./node_modules/request/lib/har.js

To install it, you can run: npm install –save fs

Running npm install –save fs doesn’t remove the error.

The file filepicker-drop.js includes this:(function (global, factory) {
typeof exports === ‘object’ && typeof module !== ‘undefined’ ? factory(require(‘jquery’), require(‘filepicker’)) :typeof define === ‘function’ && define.amd ? define([‘jquery’, ‘filepicker’], factory) :(factory(global.jQuery,global.Filepicker));
}(this, function ($,Filepicker) { ‘use strict’;

$ = ‘default’ in $ ? $[‘default’] : $;
Filepicker = ‘default’ in Filepicker ? Filepicker[‘default’] : Filepicker;

// more code here …
Is there a way to import this script inside the component?


Read more

Leave a Reply

Your email address will not be published. Required fields are marked *