Export default was not found

后端 未结 3 1097
小鲜肉
小鲜肉 2021-02-02 05:30

I have a Vue 2 project, and I\'ve written a simple function for translating months in dates, which I would like to import in one of my components, but I\'m getting an error:

相关标签:
3条回答
  • 2021-02-02 05:56

    You have to specify default explicitly:

    export default function translateDate(date) {
       ..
    }
    
    0 讨论(0)
  • 2021-02-02 06:12

    Either specify default as mentioned above, or if you're trying to export multiple items from the same file you need to import them with curly brackets.

    So you would have:

    export function doWork(){}
    export const myVariable = true;
    

    And then you'd import them in a separate file as:

    import { doWork, myVariable} from "./myES6Module"
    
    0 讨论(0)
  • 2021-02-02 06:14

    You need to set symlink setting in vue.config.js

    config.resolve.symlinks(false);
    
    0 讨论(0)
提交回复
热议问题