Introduction of third-party non-npm packages into vue-cli

problem description

I need to use an old third-party package in the project. This package does not depend on any package. The author mounts the required variables on window

.

address of the library: http://annotorious.github.io/

this is part of the source code of the library

window.anno = new Y;
Y.prototype.activateSelector = Y.prototype.ba;
Y.prototype.addAnnotation = Y.prototype.J;
Y.prototype.addHandler = Y.prototype.addHandler;
Y.prototype.addPlugin = Y.prototype.zb;
Y.prototype.destroy = Y.prototype.destroy;
Y.prototype.getActiveSelector = Y.prototype.la;
Y.prototype.getAnnotations = Y.prototype.t;
Y.prototype.getAvailableSelectors = Y.prototype.ma;
Y.prototype.hideAnnotations = Y.prototype.ea;
Y.prototype.hideSelectionWidget = Y.prototype.N;
Y.prototype.highlightAnnotation = Y.prototype.o;
Y.prototype.makeAnnotatable = Y.prototype.xc;
Y.prototype.removeAll = Y.prototype.Sb;
Y.prototype.removeAnnotation = Y.prototype.A;
Y.prototype.reset = Y.prototype.reset;
Y.prototype.setActiveSelector = Y.prototype.sb;
Y.prototype.setProperties = Y.prototype.ga;
Y.prototype.showAnnotations = Y.prototype.Da;
Y.prototype.showSelectionWidget = Y.prototype.Z;
window.annotorious || (window.annotorious = {});
window.annotorious.plugin || (window.annotorious.plugin = {});
window.annotorious.geometry || (window.annotorious.geometry = {}, window.annotorious.geometry.expand = Dd, window.annotorious.geometry.getBoundingRect = Cd);
Y.prototype.setSelectionEnabled = Y.prototype.ke;

the environmental background of the problems and what methods you have tried

I have tried google, but most of them take the introduction of jquery as an example, and the experiment has no effect.

I have referred to how to use third-party libraries in Vue.js , webpack templates how to introduce external js in the development environment , ides/shimming/-sharp-exports" rel=" nofollow noreferrer "> shimming ,

I feel that the official documentation of webpack is more reliable, but I still report an error when I try to add the following code

clipboard.png

(annotorious.min.js)


webpack.base.conf.js


main.js


anno


clipboard.png

however, when using the internal method anno.makeAnnotatable () Times error:

[Vue warn]: Error in mounted hook: "Error: Annotorious does not support this media type in the current version or build configuration."

I have also tried to introduce it into the component, and also reported an error

import anno from "../../../static/annotorious-0.6.4/annotorious.min.js"

export default {
    // ...
}
Dec.23,2021

if you look at the error, it doesn't have much to do with vue itself, it's just an error report during the mounted phase.

there is no problem with the way you quote it, but in fact, it is not so troublesome to introduce it directly into index.html. This is global registration. The problem you may encounter is that because you use webpack, when you import a package, you expect to use the syntax of import to import the package instead of using global variables directly (although it is possible, but tools such as eslint may report an error. You can also configure global variables in its settings), then you can declare external third-party variables through webpack's external setting, which is generally set for lodash and jquery. If you don't use the external approach, each import counts as a chunk, then there may be redundancy, which is not the best way.

if there are any mistakes, please correct them.


index.html introduce js


Annotorious does not support this media type in the current version or build configuration.
anno requires that the parameter is http://";>, but cannot be data:image
is that the reason?

official answer: https://github.com/annotoriou.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3be53-4d96b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3be53-4d96b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?