I'm creating a website with vue.Js (vue.cli) to show some of my work.
Actually all the interactions and experiments are made in a iframe, because I don't understand how to load and use external javascript
For example in one of my components I would like to use gio.js. To use it you need to call 4 libraries:
- jquery -> https://code.jquery.com/jquery-3.3.1.slim.min.js
- three.js -> https://threejs.org/build/three.min.js
- gio.js -> https://raw.githack.com/syt123450/giojs/master/build/gio.min.js
- data -> https://raw.githack.com/syt123450/giojs/master/assets/data/sampleData.js
So actually I write that in my component, but nothing works:
So, I would like to proper load external js files, and write regular js in my components or in an externals files.
<template>
<div class="planet">
//globalArea is for render the planisphere
<div id="globalArea"></div>
</div>
</template>
<script>
export default {
mounted() {
let jqueryScript = document.createElement('script')
jqueryScript.setAttribute('src', 'https://code.jquery.com/jquery-3.3.1.slim.min.js')
document.head.appendChild(jqueryScript);
let threeScript = document.createElement('script')
threeScript.setAttribute('src', 'https://threejs.org/build/three.min.js')
document.head.appendChild(threeScript);
let gioScript = document.createElement('script')
gioScript.setAttribute('src', 'https://raw.githack.com/syt123450/giojs/master/build/gio.min.js')
document.head.appendChild(gioScript);
let dataScript = document.createElement('script')
dataScript.setAttribute('src', 'https://raw.githack.com/syt123450/giojs/master/assets/data/sampleData.js"')
document.head.appendChild(dataScript);
}
methods: {
// Get the container to hold the IO globe
var container = document.getElementById( "globalArea" );
// Create Gio.controller
var controller = new GIO.Controller( container );
// Add data
controller.addData( data );
// Initialize and render the globe
controller.init();
}
}
</script>