猿问

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

a.js


let test = function() {

    

}


export default {

    test

}

b.js


import { test } from 'a.js'

console.log(test)  // undefined


import all from 'a.js'

console.log(all)  // {test: f}


慕运维8079593
浏览 1076回答 1
1回答

慕村225694

export default test 就可以了a.jslet test = function() {    }export default testb.jsimport test from 'a.js'console.log(test)  // undefined或者export const test = function () {}import {test} from 'a.js'
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答