For some reason I'm unable to use an array exported as an es6 module:
export const choices = [
['first', 'First'],
['second', 'Second'],
['third', 'Third'],
]
Then:
import { choices } from './constants'
console.log(choices) // undefined
If I simply declare the const
in the same file where I'm trying to use it, it works as expected.
Modules in browser contexts use relative URLs, including extension. So the import should be from './constants.js'
rather than just from './constants'
. (The latter would be fine on Node.js, though, with its currently-experimental modules support.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.