[Vuejs]-Calling External Library function inside VueJS

0👍

You don’t have to import the file using the script tag do it using import statement.

<script>

    import MediumEditor from '/static/medium-editor.min.js'

    export default {
        name: 'App',

        mounted: function() {
            var editor = new MediumEditor('.editable', {
                toolbar: {
                buttons: ['bold', 'italic', 'underline', 'anchor']
            });
            console.log('testing...')
        }
    }

</script>

Update:-

if you export the function using module.exports then importing it using import statements gives you the error Cannot assign to read-only property 'exports' of object '#<Object>. To prevent it export the function using export default.

See this:- https://github.com/webpack/webpack/issues/4039

Leave a comment