Can't js use import {} to get the properties of an object?

in a.js

export default {
  b: 1
}

then in b.js

import { b } from "./a"
console.log(b)

result error: "export "b"was not found in". / a"
babel/webpack environment
is it the wrong way I use it?

Mar.13,2021

export const b = 1;

then

import { b } from './a'

it's not the way you use it. It's something without export. Imort, module is not similar to object properties


export default is exported as a whole and can only be imported as a whole, not deconstructed.


export default {
  b: 1
}

then

import * as tmpname from './a';
console.log(tmpname.default.b)

or

import othername from './a';
console.log(othername.b)

teacher Ruan Yifeng's ES6 tutorial explains the knowledge in detail, including the usage of import, export :
Module syntax


import reference and deconstruction assignment cannot be taken as the same thing. Of course, this reference seems to be supported by babel plug-ins. But after all, it is not used correctly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bd9d-34678.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bd9d-34678.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?