I'm having an issue with Vue CLI where I need to import a JavaScript file from a different server. Unfortunately, no matter what I try, I keep encountering the same error message as indicated below.
https://i.sstatic.net/ssFy2.png
Does anyone have a solution to this problem? How can I successfully import an external JS file?
Below is the code snippet of my Vue file:
<!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> -->
<template>
<div id="app">
<p>Test</p>
<button @click="doSomething">Say hello.</button>
</div>
</template>
<script>
import TestFile from "https://.../src/TestFile.js";
export default {
data() {
return {
message: "<h1>anything</h1>"
}
},
async mounted() {
await TestFile.build();
},
methods: {
doSomething() {
alert(message);
},
},
};
</script>
<!-- Use preprocessors via the lang attribute! e.g. <style lang="scss"> -->
<style>
</style>