The problem of introducing .js files into .vue files

I want to introduce a complete js file into a vue file. So I don"t think it"s appropriate to use import to introduce all the content at once.
then I tried two more methods (I don"t know if there is one)
1. < script src= "type=" text/javascript "< / script > introduced
reported an error
2 in the vue file. < script src= "type=" text/javascript "> < / script > introduced
in the html file did not report an error, but could not find
when calling a function in vue. Is there any way to implement it? Ask for advice

I"m working on a small map project, and I want to introduce an area measurement function. I found a js file on the Internet to achieve this function
directly in html
< script src= ". / GeoUtils.js" type= "text/javascript" > < / script >
< script type= "text/javascript" src=. / AreaTool_min.js "> < / script > you can use
I want to introduce it in vue, but only export. There is always a hint that there is an undefined, I do not know what better way to solve this problem?


The script tag is introduced into the js file without parsing in

.vue.
the introduction of import is required. There are two uses:

1.import a from '../a'
2.import '../a'

the difference is that the first one you need to use export export before you can import with import.
the second is directly introduced the same as the script tag. But it works in its own js file, and you won't get it if you don't mount it in window.


who says vue can't bring in all the content at once? Please take a good look at the official documents

ide/plugins.html" rel=" nofollow noreferrer "> plug-ins

plug-ins usually add global functionality to Vue. There is no limit to the scope of plug-ins-there are generally the following:

  • add a global method or property, such as vue-custom-element
  • add global resources: directives / filters / transitions, such as vue-touch
  • add some component options through the global mixin method, such as: vue-router
  • add Vue instance methods by adding them to the Vue.prototype.
  • A library that provides its own API, and provides one or more of the functions mentioned above, such as vue-router

supplementary answer

not all plug-ins are completely suitable for use in vue projects. Many plug-ins that are not vue standard may need to be modified by yourself

.

Why is import not appropriate? Since it is a single-file mode of vue, it is best to develop it in a component-based way, so what is the js that you want to introduce?


that depends on what module specification your js file is written according to. If the method is not mounted under window, you must not be able to call


1, which cannot be introduced in this way. Unless the creat tag is inserted into html;
2 during a certain life cycle of vue, you have to make sure that the js file is loaded before vue.


https://www.cnblogs.com/moxia.


.vue you can reference global resources with window objects
I wonder if there is a better way

Menu