I have an External Java Script File something.js
function myFun(){
document.getElementById("demo").innerHTML="Hello World!";
}
export default myFun;
and this is my vue component Dashboard.vue
<template>
<div>
<button type="button" name="button" @click="">Call External JS</button>
<div id="demo"></div>
</div>
</template>
<script>
import something from "./something.js"
export default {
created(){
}
}
</script>
I have two questions.
- First how do I call this method inside the created life cycle hook to automatically run.
- Second how do I call this method by hitting the button "Call External JS"
Of-cause I know to change the content of a div can easily done by vueJS without the help of pure JS external files. But I'm asking this question for clarify the concepts of how do I use external JS files inside the vue component.
Thank you.