0

I am requiring an external script I made with function specific to Square. I want to be able to call one of the function in my mounted method. Am I able to access methods of this square.js file since I've now required it for this ?

app.js

window.Vue = require('vue');
var square = require('./square.js');

Vue.component('ShopArt',
    require('./components/ShopArt.vue').default);

new Vue({
    el: "#app",
    data() {
        return {
            shop: shop,
        }
    },
    mounted() {
        }
......
herkypam
  • 75
  • 2
  • 11
  • https://stackoverflow.com/questions/43608457/how-to-import-functions-from-different-js-file-in-a-vuewebpackvue-loader-proje Check this link out – ekpono Apr 24 '19 at 23:35

1 Answers1

0
var test = { 
 foo () { 
  console.log('foo') 
 },
 bar () { 
  console.log('bar') 
 },
 baz () { 
  console.log('baz') 
 }
}
export default test

<script> 
import test from '@/mylib'
console.log(test.foo())
...
</script>
ekpono
  • 172
  • 4