Article From:https://segmentfault.com/q/1010000012145525

These two scripts are interdependent.

The previous project was quoted directly.

Now it is

But there is a mistake in the report

How should I introduce these two third party scripts? Answer to the answer of the great God

Answer 0:

In iscroll.js and iuosselect.js files, first use EXPROT to throw out your two JS.

export function isCroll(){ Wrap up}Export function iosSelect () {wrap up}Next is your introduction. The one mistake you write now is:Import {isCroll} from'../../XX'in this parenthesis is the name of the method you have just export, and then you only need to call the name of the method in the life cycle, so you can isCroll ().

Look at the adoption of ~

Answer 1:

Encountered this is not a modular three party library, or transform it export out or put it in static, and then in index.html with script tag global introduction.

Answer 2:

Because the two third party libraries do not conform to the ES6 module specification (AMD specification), they can not be used.importIntroduced, you can try to transform the two libraries

Answer 3:
  1. Introduce < script> tag in template index.html template.
  2. Modify the source code to support ES6 module support
  export default iscroll

Answer 4:

webpackUsing the third party framework, the NPM install should be installed locally and then introduced through the import, and sometimes the configuration file needs to be added to the configuration file, for example, Vue uses jQuery to write the related configuration.

Answer 5:

It is feasible to test the NPM installation package and the conventional import.

Link of this Article: Vue introduces an external JS file

Leave a Reply

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