In the vue project, after import introduces the same file twice, the second time will be undefined

index.js
import a from"@ / views/apidocument/test/a"
console.info (a); / / has value

a.js
import c from". / c"
console.info ("bbbbbbbb",c); / / valuable
const a = {

created(){
    /* let cc = new c();
    cc.name="aaa"
    console.info(cc.name); */
    // c.name = "aaa"
}

}
export default a

c.js
import a from". / a"
console.info ("cccccccccc", a); / / undefined Why undefined?
const c = {

name: "ccc"

}
export default function () {

return {...c}

}

Nov.15,2021

your circular dependency of the es6 module causes
when the c module executes to console.info ('cccccccccc', a) ), the a variable in the a module has not yet been assigned, so the output is undefined
you can set a delay to try, it should have a value

es6 module mechanism can be found in
in-depth understanding of ES6 module mechanism
cyclic loading of JavaScript module

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-1b3c415-2c316.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-1b3c415-2c316.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?