How to use JTopo in Vue-cli project

1 Introduction

jTopo (Javascript Topology library) is a relationship based entirely on HTML5 Canvas, and topology graphical interface development kit. Its small size, high performance, be maintained by a group of hobbyists. The only feeling inadequate is that it is a pure jslibrary, did not like the use of ES6grammar, modular development can not be used like importimport,

Because bloggers are using vue-cli project to build a modular development project, we want to use third-party libraries are the best way through npm install xxxthe installation, and then in the project import xxxto use. But in the JTopoofficial website and did not find the library npmpackage, in www.npmjs.comthe search JTopo, although the library to find the npmpackage, but some of these packages are made by individual developers to modify the source code to upload, and the number of years too long, bloggers fear directly use of the words may be some strange bug, so bloggers study a little, how to vue-cliimport third-party direct project jslibraries, fortunately, we found a way to quickly and easily Ha, the method will now record, and provide demo, for your reference.

2. Solution

We know that, no matter what the project, the final package by running in the browser is certainly a htmlfile in Vuethe root directory is index.html, will be in the file webpackafter the package build.jsfiles <script>into the label manner, in that case, we dare imagine, we can assume jtopo.jsthat webpackpackaged the output file, we have to manually index.htmlfile by <script>is not ready to use it the way into the label. Through the experiment, literally.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>JTopoInVue</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="/lib/jtopo-0.4.8-min.js"></script>
    <script src="/dist/build.js"></script>
  </body>
</html>

After this introduction, we can follow the project jtopoas an official document of the library use it. demo here Mengchuo

3. deficiencies at

jtopoOfficial website also provides a toolbar, the toolbar functionality is toolbar.jsimplemented, and the jsfile inside relied jQuery, so in order to use the toolbar in the project must be installed jQuery, and the bloggers do not use the toolbar in the project, so there is no continuing research in this area if there is little demand partners can use their own research.

(Finish)

Guess you like

Origin www.cnblogs.com/wangjiachen666/p/11022686.html