久久久久久久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 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送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']);
                  });
                  

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

                  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 代碼,但我可以繼續(xù)使用 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 完全向后兼容,所以基本上你可以將整個應(yīng)用程序視為 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 管道中添加一個轉(zhuǎn)譯步驟,以通過 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']);
                  });
                  

                  請注意,上面的代碼不會轉(zhuǎn)換 ScheduleMain.js,但如果您愿意,您可以輕松地做到這一點,以便繼續(xù)使用 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 需要一些配置 - 文檔 將指導(dǎo)您完成此操作.你會想要 es2015 和 react 預(yù)設(shè).

                  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'));
                  

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

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

                  相關(guān)文檔推薦

                  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?(是否可以將標(biāo)志傳遞給 Gulp 以使其以不同的方式運行任務(wù)?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務(wù))
                  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. 主站蜘蛛池模板: 第一色在线 | 亚洲成人精品国产 | 一级午夜aaa免费看三区 | 男人视频网站 | 免费午夜视频在线观看 | 久草中文网 | 亚洲成人av在线 | 国产成人在线视频免费观看 | 久久国产精品免费视频 | 亚洲一av | 久久国产综合 | 激情综合五月 | 美女黄18岁以下禁止观看 | 97久久精品午夜一区二区 | 日本成人福利视频 | 欧美另类视频在线 | 精品综合久久 | 久久69精品久久久久久久电影好 | 91玖玖| 琪琪午夜伦伦电影福利片 | 亚洲日韩中文字幕一区 | 麻豆视频在线免费观看 | 日韩高清中文字幕 | 国产成人精品a视频一区www | 久久精品一 | 欧美一区二区三区在线视频 | a在线视频| 福利视频网站 | 成人一区二区三区在线 | 2023亚洲天堂 | 欧美一区二区三区国产精品 | 少妇午夜一级艳片欧美精品 | 日本精品免费在线观看 | 亚洲成av | www.99久久.com | 日本不卡一区二区三区在线观看 | 九色av| 狠狠爱综合网 | 国产精品久久久久久久免费大片 | 91精品久久久 | 国产精品视频一 |