Vue introducing non-js library of npm
Vue project sometimes need some of js library does not export, import can not be introduced, then the following should be used
1 can use the script tag incorporated index.html page, of course, also be used cdn address.
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Map</title> 5 <meta charset="utf-8"> 6 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 7 <link rel="shortcut icon" type="image/x-icon" href="./static/img/favicon.ico"/> 8 <script src='./static/libs/three/three.min.js'></script> 9 <script src="./static/libs/three/GLTFLoader.js"></script> 10 </head> 11 <body> 12 <div id="app"></div> 13 <!-- built files will be auto injected --> 14 </body> 15 </html>
2. Use window.moduleName in use in main.js
Vue.prototype may be placed in, it can be provided with such components.
1 var THREE = window.THREE 2 var GLTFLoader = THREE.GLTFLoader 3 Vue.prototype.THREE = THREE