[Vuejs]-Importing Vanilla js file to Vue.js component

9👍

You can import the script within your vue component with either

  1. import

    import '../src/js/drag-and-drop.js';

  2. require

    require('../src/js/drag-and-drop.js');

in the script section of your component.

e.g.

<template>
  <!-- vue component markup -->
</template>

<script> 
import drag from '../src/js/drag-and-drop';
export default {
  name: 'you-vue-component',
}    
</script>
👤Julxzs

Leave a comment