Home >Web Front-end >JS Tutorial >Detailed explanation of module syntax in JavaScript ES6

Detailed explanation of module syntax in JavaScript ES6

黄舟
黄舟Original
2017-10-31 10:17:571714browse

import

First type: import

Writing:

import { awaitAddGoodsList, goodsSkuList ,setSku} from '@/api/marketActivity'

Quote :

mounted(){
awaitAddGoodsList//直接使用
}

Second type: import

Writing:

import * as limitedBuy from '@/utils/limitedBuy'

Quote:

mounted(){
  limitedBuy.demo();
}

export

The first way of writing:

.export function demo(){}

The second way of writing:

function demo()
  export {demo}

The third way can also be renamed

export {demo as demo1}这样import的时候就demo1

export default function(){}

import demo form 'xxx.js'

No need for braces

The above is the detailed content of Detailed explanation of module syntax in JavaScript ES6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn