Tim Liberty
Tim Liberty

Reputation: 2149

importing js file in Vue project throws error

I am trying to use this plugin https://www.npmjs.com/package/mobius1-selectr

I did a npm install mobius1-selectr

and imported it in my main.js

import 'mobius1-selectr/dist/selectr.min.css';
import 'mobius1-selectr/dist/selectr.min.js';

but as soon I import I get this exception:

You must supply either a HTMLSelectElement or a CSS3 selector string.

which comes from the source of selectr.

Is the import not to be done this way in webpack / main.js?

What am I doing wrong? Any help is appreciated.

Upvotes: 1

Views: 206

Answers (1)

dfsq
dfsq

Reputation: 193301

Yes your imports are incorrect. This library uses UMD to export Selectr constructor. You are using Webpack so default import in your case should work:

import Selectr from 'mobius1-selectr'

Upvotes: 1

Related Questions