久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='SQ13q'><tr id='SQ13q'><dt id='SQ13q'><q id='SQ13q'><span id='SQ13q'><b id='SQ13q'><form id='SQ13q'><ins id='SQ13q'></ins><ul id='SQ13q'></ul><sub id='SQ13q'></sub></form><legend id='SQ13q'></legend><bdo id='SQ13q'><pre id='SQ13q'><center id='SQ13q'></center></pre></bdo></b><th id='SQ13q'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SQ13q'><tfoot id='SQ13q'></tfoot><dl id='SQ13q'><fieldset id='SQ13q'></fieldset></dl></div>

      1. <small id='SQ13q'></small><noframes id='SQ13q'>

      2. <legend id='SQ13q'><style id='SQ13q'><dir id='SQ13q'><q id='SQ13q'></q></dir></style></legend>
        • <bdo id='SQ13q'></bdo><ul id='SQ13q'></ul>
        <tfoot id='SQ13q'></tfoot>

        我可以在同一個 React 代碼庫中同時使用 ES6 和

        Can I use both ES6 and ES5 in the same React codebase?(我可以在同一個 React 代碼庫中同時使用 ES6 和 ES5 嗎?)
            • <bdo id='0GxF2'></bdo><ul id='0GxF2'></ul>
                  <tbody id='0GxF2'></tbody>

                  <i id='0GxF2'><tr id='0GxF2'><dt id='0GxF2'><q id='0GxF2'><span id='0GxF2'><b id='0GxF2'><form id='0GxF2'><ins id='0GxF2'></ins><ul id='0GxF2'></ul><sub id='0GxF2'></sub></form><legend id='0GxF2'></legend><bdo id='0GxF2'><pre id='0GxF2'><center id='0GxF2'></center></pre></bdo></b><th id='0GxF2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0GxF2'><tfoot id='0GxF2'></tfoot><dl id='0GxF2'><fieldset id='0GxF2'></fieldset></dl></div>
                • <legend id='0GxF2'><style id='0GxF2'><dir id='0GxF2'><q id='0GxF2'></q></dir></style></legend>

                  <small id='0GxF2'></small><noframes id='0GxF2'>

                • <tfoot id='0GxF2'></tfoot>
                • 本文介紹了我可以在同一個 React 代碼庫中同時使用 ES6 和 ES5 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有以下 gulpfile.js:

                  I have the following gulpfile.js:

                  var gulp = require('gulp');
                  var browserify = require('gulp-browserify');
                  var concat = require('gulp-concat');
                  
                  gulp.task('browserify', function() {
                      gulp.src('js/ScheduleMain.js')
                        .pipe(browserify({transform:'reactify'}))
                        .pipe(concat('ScheduleMain.js'))
                        .pipe(gulp.dest('static/dist/js'));
                      gulp.src('js/ConfidenceMain.js')
                        .pipe(browserify({transform:'reactify'}))
                        .pipe(concat('ConfidenceMain.js'))
                        .pipe(gulp.dest('static/dist/js'));
                  });
                  
                  gulp.task('default',['browserify']);
                  
                  gulp.task('watch', function() {
                      gulp.watch('src/**/*.*', ['default']);
                  });
                  

                  如您所見,我有兩個需要轉換的源文件.ScheduleMain.js 是用 es5 編寫的,構建良好.我想在 es6 中編寫我的新應用程序(ConfidenceMain.js),并可能將其轉換為 es5 進行構建.我對如何做到這一點有點困惑(或者更確切地說,如果它完全被推薦).

                  As you can see I have two source files that need transforming. ScheduleMain.js is written in es5 and builds fine. I want to write my new application (ConfidenceMain.js) in es6 and possible transform it to es5 for build. I am a bit confused on how to do this (or rather if it is at all recommended).

                  底線:盡管之前在同一代碼庫中有其他項目的 es5 代碼,但我可以繼續使用 es6 語法編寫的新 React 項目嗎?

                  Bottom line: Can I move forward with new react projects written in es6 syntax despite having es5 code previously for other projects in the same code base?

                  推薦答案

                  是的,你可以混合使用 ES6 和 ES5 - ES6 完全向后兼容,所以基本上你可以將整個應用程序視為 ES6,但只能使用新的新代碼中的語法和功能.

                  Yes, you can mix both ES6 and ES5 - ES6 is fully backwards compatible, so essentially you could think of your entire app as ES6, but only use the new syntax and functionality in new code.

                  您需要在 gulp 管道中添加一個轉譯步驟,以通過 babel 傳遞您的代碼并將其編譯為 ES5.像這樣的:

                  You would need to add a transpilation step to your gulp pipeline to pass your code through babel and compile it down to ES5. Something like this:

                  var gulp = require('gulp');
                  var browserify = require('gulp-browserify');
                  var concat = require('gulp-concat');
                  var babel = require('gulp-babel');
                  
                  gulp.task('browserify', function() {
                      gulp.src('js/ScheduleMain.js')
                        .pipe(browserify({transform:'reactify'}))
                        .pipe(concat('ScheduleMain.js'))
                        .pipe(gulp.dest('static/dist/js'));
                      gulp.src('js/ConfidenceMain.js')
                        .pipe(babel())
                        .pipe(browserify({transform:'reactify'}))
                        .pipe(concat('ConfidenceMain.js'))
                        .pipe(gulp.dest('static/dist/js'));
                  });
                  
                  gulp.task('default',['browserify']);
                  
                  gulp.task('watch', function() {
                      gulp.watch('src/**/*.*', ['default']);
                  });
                  

                  請注意,上面的代碼不會轉換 ScheduleMain.js,但如果您愿意,您可以輕松地做到這一點,以便繼續使用 ES6 功能 - 只需通過 babel() 將其通過管道同樣的方式.

                  Note that the code above wouldn't transpile ScheduleMain.js but you could easily do that if you wanted, to enable the use of ES6 features going forwards - just pipe it through babel() in the same way.

                  請注意,babel 需要一些配置 - 文檔 將指導您完成此操作.你會想要 es2015 和 react 預設.

                  Note that babel will require some configuration - the documentation will guide you through this. You'll want the es2015 and react presets.

                  編輯:鑒于您使用 browserify,更簡潔的方法可能是使用 babelify 改為:

                  Edit: Given your use of browserify, a cleaner approach might be to use the babelify transform instead:

                  gulp.src('js/ConfidenceMain.js')
                    .pipe(browserify({transform:'babelify'}))
                    .pipe(concat('ConfidenceMain.js'))
                    .pipe(gulp.dest('static/dist/js'));
                  

                  這篇關于我可以在同一個 React 代碼庫中同時使用 ES6 和 ES5 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                • <small id='vnk58'></small><noframes id='vnk58'>

                    <i id='vnk58'><tr id='vnk58'><dt id='vnk58'><q id='vnk58'><span id='vnk58'><b id='vnk58'><form id='vnk58'><ins id='vnk58'></ins><ul id='vnk58'></ul><sub id='vnk58'></sub></form><legend id='vnk58'></legend><bdo id='vnk58'><pre id='vnk58'><center id='vnk58'></center></pre></bdo></b><th id='vnk58'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vnk58'><tfoot id='vnk58'></tfoot><dl id='vnk58'><fieldset id='vnk58'></fieldset></dl></div>
                  1. <legend id='vnk58'><style id='vnk58'><dir id='vnk58'><q id='vnk58'></q></dir></style></legend>

                    <tfoot id='vnk58'></tfoot>
                    • <bdo id='vnk58'></bdo><ul id='vnk58'></ul>

                              <tbody id='vnk58'></tbody>
                          1. 主站蜘蛛池模板: 狠狠干美女| 一级黄色片在线免费观看 | 亚洲欧美激情精品一区二区 | 男女羞羞在线观看 | 91精品国产日韩91久久久久久 | 国产日韩久久 | 国产精品久久久久久久久久久久久久 | 国产精品久久久久久一区二区三区 | 中文字幕一区二区三 | 成人免费看片 | 久久综合99 | 欧美成人专区 | 交专区videossex农村 | 2020国产在线 | 久久久久9999 | 欧美一区二区三区 | 久久精品国产一区 | 国产免费拔擦拔擦8x高清 | h网站在线观看 | 亚洲综合视频 | 日韩一区二区三区视频 | 综合国产第二页 | 欧美日韩在线电影 | 国产精品久久av | 91精品国产综合久久久亚洲 | 亚洲综合无码一区二区 | 草比网站 | 91视频一88av | 欧美黄a | 亚洲国产精品网站 | 久久久久久久久毛片 | 午夜成人免费视频 | 亚洲视频三区 | 天天爽夜夜操 | 精品日韩一区二区三区 | 亚洲精品无 | 成人免费网站www网站高清 | 一区二区三区在线免费看 | 日韩视频中文字幕 | 久久精品久久久久久 | 一级毛片色一级 |