您现在的位置:首页 >> 前端 >> 内容

ES6-进阶“编程开发”

时间:2017/8/23 9:11:00 点击:

  核心提示:import export//假设我们有两个js文件: index.js和content.js,现在我们想要在index.js中使用content.js返回的结果,我们要怎么做呢?//content....

import export

//假设我们有两个js文件: index.js和content.js,现在我们想要在index.js中使用content.js返回的结果,我们要怎么做呢?

//content.js
export default 'A cat'    
export function say(){
    return 'Hello!'
}    
export const type = 'dog' 
//index.js
import { say, type } from './content'  
let says = say()
console.log(`The ${type} says ${says}`)  //The dog says Hello

Tags:ES S6 6进 进阶 
作者:网络 来源:送你一个大西瓜