[Vuejs]-Can I require/import files for a ViewModel in Vue.js?

0๐Ÿ‘

โœ…

I figured it out.
I needed to import and export in a specific way so my Example.vue:

<template>
    <div>
        <h1>Example: {{message}}</h1>
    </div>
</template>

<script>
    import Example from '../ViewModels/Example';

    export default {
        data() {
            return new Example();
        }
    }
</script>

and my Example.js class file:

export default class Example {
    constructor() {
        this.message = "Hello World";
    }
}

Leave a comment