Home > Web Front-end > JS Tutorial > body text

Detailed explanation of module syntax in JavaScript ES6

黄舟
Release: 2017-10-31 10:17:57
Original
1658 people have browsed it

import

First type: import

Writing:

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

Quote :

mounted(){
awaitAddGoodsList//直接使用
}
Copy after login

Second type: import

Writing:

import * as limitedBuy from '@/utils/limitedBuy'
Copy after login

Quote:

mounted(){
  limitedBuy.demo();
}
Copy after login

export

The first way of writing:

.export function demo(){}
Copy after login

The second way of writing:

function demo()
  export {demo}
Copy after login

The third way can also be renamed

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!