为了账号安全,请及时绑定邮箱和手机立即绑定

js import 一个对象同时解构 出现undefined

js import 一个对象同时解构 出现undefined

慕运维8079593 2018-12-12 18:18:04
a.jslet test = function() {    }export default {    test}b.jsimport { test } from 'a.js'console.log(test)  // undefinedimport all from 'a.js'console.log(all)  // {test: f}
查看完整描述

1 回答

?
慕村225694

TA贡献1880条经验 获得超4个赞

export default test 就可以了


a.js


let test = function() {

    

}


export default test

b.js


import test from 'a.js'

console.log(test)  // undefined



或者


export const test = function () {}


import {test} from 'a.js'


查看完整回答
反对 回复 2019-01-19
  • 1 回答
  • 0 关注
  • 1075 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号