doesn't prevent us from prying into the ES6 module standards.Defining a module does not require specialized work, because the function of a module is to provide APIs externally, so just export with exoprt:Way One, a.jsExport var a = 1;Export var obj = {name: ' abc ', AGE:20};Export function Run () {...}Mode two, B.jsvar a = 1;var obj = {name: ' abc ', AGE:20};function run () {...}Export {A, obj, run}Use the Import keyword when using modules, such as:Import {Run as Go} from ' a 'Run ()If you wan
(Typescript Transpiler), we can casually use the new language features provided by ES6 without regard to system compatibility issues. Because the TSC can be used to convert the high version of JS code to a lower version of the JS code.
3. First Typescript procedure
Typescript website provides a playground page, so that we do not install the TSC can also compile, run Typescript code: https://www.typescriptlang.org/play/index.html
3.1. Enter the follo
using let, so that it does not affect the variable of the same name outside the scope, which is the same behavior as most other programming languages.
Click the picture to view the larger image
Preventing duplicate declarations of variables
ES6 does not allow you to repeatedly declare variables of the same name with let or const in the same scope. This is useful to prevent duplicate declarations of function expressions in different JS libraries.
For example, the Add function in the following
Sublime text is almost any developer's prerequisite application in its toolbox. Sublime text is a cross-platform, highly customizable, advanced text editor for a fully functional IDE (a scarce resource) and for matching command-line editors, such as Vim and Emacs (with a steep learning curve).
One of the reasons why Sublime text is so popular is its extensible plug-in architecture. This allows developers to extend the core functionality of sublime by easily using new features, such as code comp
This paper introduces the construction process of vue2.0+webpack environment.
1. First create a new directory Vue-wkdemo, this is our project directory. Execute the NPM init command to generate the Package.json file. After you perform NPM init, you will be prompted to fill in some project information, always return to the default, or directly execute NPM init-y to skip the inquiry step directly.
2. Installation Project Dependencies
NPM Install Webpack webpack-dev-server vue-loader vue-
for us and has specific colors for annotations. If you try to write some code, you will find that, it also supports matching of parentheses and even error prompts.
This example shows the power of the Language Service. The functions mentioned above are implemented by the Language Service.
Initial look code host package
Any one or more services can be integrated into vs in the form of packages, and language services are no exception. In fact, language services must be extended in this way. I
1, the first global installation BABEL-CLI, the input command npm install babel-cli-g2, input CD d:\es6 ; ---Enter the folder path 3, enter NPM init, go to the---(Guide you to create a Package.json file, including name, version, author, etc.) 4, enter NPM install--save-dev BABEL-CLI;---(Install command line transcoding BABEL
IntroducedVue.js is a client JS library that can be used to develop a single page application. For a project selection, I looked up and down angular, react, Vuejs, to the former two is to admire, the latter is love. Because it's neat and clean, and there's a huge web of components to implement. Even if there are not many documents, I would like to choose it. Next, we start by building a starting project, and we'll go through the concepts and components involved in the development process.Vue.jsA
Write in front:This configuration supports ES6, less1. FirstGive the initial directory structureGives the directory structure after executing the gulpGives the directory structure after executing gulp--p2.package.json is a write. The file describes the configuration information for the NPM package (author, profile, package dependencies, etc.) and the required modules.{ "name": "Grunttest", "version": "1.0.0", "description": "", "main": "Gulpfile.js"}3.gulpfile.js adding a task to performvar
Webpack is a module packager, any static resources (js, css, pictures, Etc.) can be regarded as modules, and then can be interdependent between the modules, through the Webpack module processing, can be packaged into the static resources we Want.Gulp Packaging is the js, css, pictures and other packaging separately, but Webpack is all the static resources packaged together, so a request can Be.Features of • Support Commonjs (require) and AMD modules, which means you can migrate old items without
I. OverviewES6 is now in its prime, companies are trying to use, and as a front-end engineer ES6 is also the highlight of Technology. however, the current browser is not particularly compatible with ES6 support, and ultimately the need to convert ES6 to Es5,webpack using the babel-loader loader for conversion, its configuration is very easy.second, the configuration Babel-loaderIf you do not have the ES6 gr
Prerequisite: Nodejs and NPM have been installed#全局安装webpack Automated Building tools, functional Management projects; Webpack-dev-server is a development tool that provides hot Module replacement functionality# Webpack Introduction: http://webpack.github.io/docs/what-is-webpack.htmlInstall -g webpack webpack-dev-server#在项目文件夹路径下, Initialize the NPM projectNPM Init#安装webpack和webpack-dev-server to the projectInstall Webpack Webpack-dev-server--save-dev#可选:#安装css-loader, style-loader, image-loader
Solve the error reported by UglifyJs during iview packaging, iviewuglifyjs
The run time is OK when npm run dev is used, but iview reports an error when npm run build is packaged,
As follows:
The reason is that es6 syntax is used in iview, but uglifyJs does not support it. Open the build/webpack. prod. conf. js file and you can see
// UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/
concept of chunk ,Chunk represents a file , by default Webpack input is a portal file, the output is a file, this file is a chunk, Chunkid is the output when giving each file a unique identifier Id,chunkhash is the MD5 value of the file content, and name is the key value specified in the entry.Module.exports = { entry: { collection: './src/main.js ' //collection is chunk's name, chunk's entry file is Main.js } , output: { path: './dist/js ', filename: ' [name].
modules for whic H This installation technique is useful. When we use NPM scripts, NPM looks for locally installed webpack, which resolves the version issue, and each project uses a local installation webpack, which does not affect each other. so local installation is recommendedCore concepts of the 3,webpack configuration file (webpack.config.js)After installing Webpack, we also carried out a simple packaging operation, which is actually the basis of webpack as a packaging tool. If our JS code
Using ES6
To use ES6, we need loader.
Modify webpack.config.js File:
Module.exports = { './index.js ', output: { ' bundle.js ', path: __dirname }, module: { loaders: [ /\.js$/, loader: ' Babel ', exclude: '/node_modules/'} ] }};We Add Module property, which are an object. We define the Loaders property Here which are an array of objects.
Test: It is a regex, would inclu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.