2月7日-vue-cli(2-1). ES6中的import和export

Profile Picture
Published on Feb 7, 2020🌏 Public

二、export和import

user.js

var info={
    username:'小明',
    age:12
}

var sex='女';

function changeName(newname){
    info.username=newname;
}

export {info , changeName } //通过export开放info和changeName
<script type="module">
    import {info , changeName }  from './user.js'
    console.log(info)
    changeName('asdf');
    console.log(info)
</script>