Reputation: 542
Given the files below:
mutation-types.js
export const SET_VALUE = 'SET_VALUE'
export const SET_PLACEHOLDER = 'SET_PLACEHOLDER'
my-file.js
import * as types from './mutation-types'
gives an error saying Uncaught TypeError: types__WEBPACK_IMPORTED_MODULE_1_.default is undefined. Even the official vuex repo uses this syntax with the same version of Vue, 3. Here you can check it.
Why isn't it possible to use the import like import * as name from './something'
?
Upvotes: 1
Views: 110
Reputation: 4170
You can see VueX is importing from ../api
(api/index.js), which does not write export const
as you do.
If you read the message closely it says ".default is undefined". So try it with export default
.
Take an example from
Canonical way to define common constants in Vue.js
const SET_VALUE = 'SET_VALUE'
const SET_PLACEHOLDER = 'SET_PLACEHOLDER'
export default {
SET_VALUE: SET_VALUE,
SET_PLACEHOLDER: SET_PLACEHOLDER
}
Upvotes: 1