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:
export ‘default’ (imported as ‘translateDate’) was not found in ‘@/utils/date-translation’
The relative file path from the src folder is correct, and I am exporting the function like this:
JavaScript
x
4
1
export function translateDate(date) {
2
// my code
3
}
4
And then I am importing it in the component like this:
JavaScript
1
2
1
import translateDate from '@/utils/date-translation'
2
What am I doing wrong?
Advertisement
Answer
You have to specify default
explicitly:
JavaScript
1
4
1
export default function translateDate(date) {
2
..
3
}
4