How to pass in the window object when vue introduces the native js plug-in

there is a plug-in written by native js: springy.js , which uses the window object.
the traditional script tag is introduced to automatically pass in window objects.

but how do you do this under vue?

spring.js plugin format:

clipboard.png
this:

clipboard.png

If

is introduced in the traditional way, the this points to the window object, so the window object will be used normally.
but under vue, this will be undefined .

excuse me, is there any good solution?

Jun.11,2021

imports-loader, you can try

clipboard.png

https://webpack.js.org/loader.


main.js
import springy from './...'
Vue.prototype.springy = springy;

can also be introduced using script tags under vue

Menu