How to include local script files in Vue
Import like this
<script>
import * as myKey from '.src/..';
export default {
}
</script>
How can I include 3rd party JavaScript files in vue.js?
There seems to be no real solution, which means no solution without modifying the original 3rd party script.
The reason is that the 3rd party script consists of an "Immediately Invoked Function Expression" (IIFE):
(function (win) {
win.MyUtil = {
"func1": function func1() { ... },
"func2": function func1() { ... }
}
}(window));
So I had to modify the third party script, which is what I wanted to avoid. Thanks to Rishinder (VPaul) who pointed to the right direction.
Now it is a "Module" that exports an object:
var MyUtil
export default MyUtil = {
func1: function() { ... },
func2: function() { ... }
}
In the Vue.js single file component file (*.vue) it can be imported like this (if it is in the same folder as the *.vue file):
<script>
import MyUtil from "./my_util.js"
// code using MyUtil goes here
</script>
Related Topics
Disable F5 and Browser Refresh Using JavaScript
Array Map into String With Line Break - React
How to Intercept Button Click Inside Uiwebview on Ios
How to Make Mongoose Not Insert Empty Array or Object Fields into a Document
Node Js - Function to Return Array of Objects Read from Sequelize Database
Javascript Dashes in Phone Number
Check If My HTML Table Is Empty Using JavaScript
React - How to Open Pdf File as a Href Target Blank
Node Server Running But Localhost Refusing to Connect
Get a List of Dates Between Two Dates Using JavaScript
Filereader Onload With Result and Parameter
How to Append My Data in Nested Object
Pass a String With Double and Single Quotes as Parameter to JavaScript Function
How to Conditionally Include Script Element in Angular
How to Add Counter in Angular 6