{"id":1934,"date":"2023-03-25T14:26:38","date_gmt":"2023-03-25T06:26:38","guid":{"rendered":""},"modified":"2023-03-25T14:26:38","modified_gmt":"2023-03-25T06:26:38","slug":"ES6 \u6a21\u5757","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1934.html","title":{"rendered":"ES6 \u6a21\u5757"},"content":{"rendered":"
\n
\u547d\u540d\u5bfc\u51fa: \u4ee5\u540d\u79f0\u533a\u5206\u7684\u5bfc\u51fa\u79f0\u4e3a\u547d\u540d\u5bfc\u51fa\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u547d\u540d\u5bfc\u51fa\u5bfc\u51fa\u591a\u4e2a\u53d8\u91cf\u548c\u51fd\u6570\u3002<\/span> <\/code>\n <\/div>\n <\/code>\n <\/div>\n <\/code>\n <\/div>\n <\/code>\n <\/div>\n <\/code>\n <\/div>\n
\n \u9ed8\u8ba4\u5bfc\u51fa: \u4f7f\u7528\u9ed8\u8ba4\u5bfc\u51fa\u6700\u591a\u53ef\u4ee5\u5bfc\u51fa\u4e00\u4e2a\u503c\u3002<\/span> <\/p>\n\u5bfc\u5165\u6a21\u5757<\/h3>\n
\u547d\u540d\u5bfc\u51fa\u548c\u5bfc\u5165<\/h2>\n
\n\/\/Named export<\/span> in class<\/span>\nclass <\/span>Nokia{\n\/\/properties<\/span>\n\/\/methods<\/span>\n}\nexport {Nokia}; \/\/Named export\n\/\/Named export in functions<\/span>\nfunction show(){\n}\nexport {show};\n\/\/Named export in Variables<\/span>\nconst a = 10;\nexport {a};<\/pre>\n
\nclass <\/span>Nokia{\n\/\/properties<\/span>\n\/\/methods<\/span>\n}\nfunction show(){\n}\nconst a = 10;\nexport {Nokia, show};<\/pre>\n
\u5bfc\u5165\u547d\u540d\u5bfc\u51fa<\/h3>\n
\nimport {Nokia, show} from '.\/Mobile.js'<\/span>;<\/pre>\n
\nimport * as device from '.\/Mobile.js'<\/span>; \/\/ Here, the device is an alias, and Mobile.js is the module name.<\/span><\/pre>\n
\ndevice.Nokia \/\/if <\/span>we have a class <\/span>Nokia<\/span>\ndevice.show \/\/ if <\/span>we have a function show<\/span>\ndevice.a \/\/ if <\/span>we have a variable a<\/span><\/pre>\n
\u793a\u4f8b-\u547d\u540d\u5bfc\u51fa\u548c\u5bfc\u5165<\/h3>\n
\n