babel

Vue JS Vuetify menu named slot “activator” is not binding to the template, but going to “default”

喜你入骨 提交于 2019-12-06 09:33:22
I cannot seem to get the example code for a Vuetify v-menu to work inside my PWA app, but it works normally in a Fiddle (e.g. https://jsfiddle.net/tjw13yz4/27/ ) The problem is: the activator slot content doesn't appear. By debugging the vuetify source code, I have found that the activator template turns up under the "default" slot (where all the hidden content is), not in the named activator slot (where the visible button/click area should be). I have simplified my app to the bare bones (originally I had dynamic components, forms, APIs etc) so I've reduced it down to just a v-menu inside the

webpack中配置babel

别等时光非礼了梦想. 提交于 2019-12-06 08:35:59
为什么要配置babel? 因为在webpack中,默认只能处理一部分es6的语法,一些更高级的es6和es7语法webpack不能处理,这时就需要第三方的loader即babel来帮助webpack来处理这些高级的语法 配置步骤 1、先通过两套命令来安装loader: npm i babel-core babel-loader babel-plugin-transform-runtime -D npm i babel-preset-env babel-preset-stage-0 -D 2、在webpack.config.js配置文件中的modules节点中添加一个规则 module:{ rules:[ {test:/\.js$/,use:'babel-loader',exclude:/node_modules/} ] } 3、在根目录下创建 .babelrc配置文件 作用:用来打包编译node_modules中所有第三方js文件,否则会非常小号cpu,打包速度慢,项目会无法运行  { “presets”:["env","satge-0"], "plugins":["transform-runtime"] } 4、在main.js中写一段高级语法来进行测试 class Preson{ static info = {name:'sy',age:22} } console.log

ES6 编译 ES5 环境搭建

旧时模样 提交于 2019-12-06 07:08:53
目录结构 scripts main.es6 products.es6 temp gulpfile.js package.json index.html 文件内容 package.json { "devDependencies": { "browserify": "^11.2.0", "gulp": "^3.9.0", "gulp-babel": "^5.2.1", "gulp-buffer": "0.0.2", "gulp-clean": "^0.3.1", "gulp-uglify": "^1.4.1", "vinyl-source-stream": "^1.1.0" } } gulpfile.js var gulp = require('gulp'), babel = require('gulp-babel'), browserify = require('browserify'), source = require('vinyl-source-stream'), buffer = require('gulp-buffer'), uglify = require('gulp-uglify'), clean = require('gulp-clean') ; gulp.task('help', function () { console.log( `使用帮助: gulp

2019年11月第五周前端问题汇总

自作多情 提交于 2019-12-06 06:22:10
2019-11-26 自执行函数 //一般来说,我们在使用函数时,通常会分这样几步 //1、定义一个函数 function func(){ console.log(1) } //2、定义一个变量接受func函数 或直接调用 var a = func(); //2、函数调用 a() //输出1 //自执行函数就是将上面综合,定义时直接调用 var b = function (i){ console.log(i) }(2) //输出2 //理论上来说,自执行的匿名函数可以写为 function(x){return x*x}(3),但是由于JavaScript的语法解析问题,这么写会报syntaxError错误,所以需要用括号把整个函数定义起来,即 (function (x){return x*x})(3) JavaScript代码执行顺序。 JavaScript的代码都是按照单线程执行的,即一段代码执行完成后才会开始下一段代码。 //例如:下面代码中,先执行for循环,执行到循环内部的定时函数时,因为时间设置为0,此时应该立即输出i的值。但是由于当前for循环未执行完毕,所以定时函数会留在循环函数执行完毕后再执行,此时i为4,所以会输出三个4 for(var i=1;i<=3;i++){ setTimeout(function(){ console.log(i); //输出:4,4,4

React-Native 0.57: 'Can't find variable: require' with metro-react-native-babel-preset

半城伤御伤魂 提交于 2019-12-06 04:36:13
I started a multiplatform project with code sharing between react-native and react-js. So I have a webpack setup for browser/Electron, and a react-native 0.57 setup for Android/iOS. The problem I'm having right now is the following: Can't find variable: require It might be a very bald question, but do I need anything else? I read, that React-native should support require by itself, but couldn't find anything related to this setup yet. .babelrc {"presets": ["module:metro-react-native-babel-preset"]} I'm also using @babel/polyfill and @babel/runtime on browser side, but I wonder if they would

Broken autobinding in arrow function for referenced node modules when using react-native with react-relay

被刻印的时光 ゝ 提交于 2019-12-06 03:29:53
I'm using react-native and react-relay, therefore I've the following .babelrc file: { "sourceMaps": "both", "presets": [ "./plugins/babelRelayPlugin", "react-native" ], "passPerPreset": true } Adding a dependency which uses arrow functions in their components as the MKIconToggle from react-native-material-kit ( https://github.com/xinthink/react-native-material-kit ) doesn't get transpiled correctly and the this reference is lost/wrong. The original code which ultimately causes the error looks like the following: _onLayout = (evt) => { this._onLayoutChange(evt.nativeEvent.layout); if (this

babel详解

瘦欲@ 提交于 2019-12-06 00:07:21
https://segmentfault.com/a/1190000019718925 https://babeljs.io/blog/2019/03/19/7.4.0#core-js-3-7646-https-githubcom-babel-babel-pull-7646 https://juejin.im/post/5ce693b45188252db303ff23 https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md https://github.com/zloirock/core-js/tree/master#babelruntime https://juejin.im/post/5d7efbbb6fb9a06b2650c74a 来源: https://www.cnblogs.com/little-ab/p/11952798.html

快速了解ES6

[亡魂溺海] 提交于 2019-12-05 22:25:56
ECMAScript6(简称ES6),是JavaScript的下一代标准,因为ES6是在2015年发布的,所以又称ECMAScript2015(ES6 === ECMAScript2015) 目前不是所有的浏览器都完全兼容ES6,但很多程序猿已经开始使用ES6了,所以了解并逐步掌握ES6,甚至在你的项目中使用ES6,是非常有必要的,至少也要看得懂小伙伴写的ES6代码吧? 在说ES6之前,我们先来了解下Babel,这是个什么鬼?它是一个广泛使用的ES6转码器,可以将我们写的ES6代码转换成能在当前所有浏览器中执行的ES5代码。你可以在你习惯使用的工具中集成Babel,方便它来工作,具体使用请查看Babel官网( http://babeljs.io ) 下面我们来看下最常用的一些ES6特性: let,const class,extends,super arrow functions template string destructuring default rest arguments let,const let是用来声明变量的,与var相似,const是定义常量的。我们先来看下面的例子 while (true) { var name = 'obama'; console.log(name); //obama break; } console.log(name); //obama

React Native v0.56: Cannot read property 'filename' of undefined at PluginPass.JSXOpeningElement

痞子三分冷 提交于 2019-12-05 20:37:30
问题 I just updated the React Native from 0.55 to 0.56. However, when I tried to run the code (react-native run-android OR run-ios), bundling stops to this point: Loading dependency graph, done. error: bundling failed: TypeError: Cannot read property 'filename' of undefined at PluginPass.JSXOpeningElement ({path_to_my_project}/react-native/node_modules/babel-plugin-transform-react-jsx-source/lib/index.js:32:39) This is my .babelrc: { "presets": [ "react-native" ], "env": { "development": {

Jest fails to transpile import from npm linked module

你说的曾经没有我的故事 提交于 2019-12-05 16:53:23
I have a project with multiple modules (using Lerna ) and I want to use Jest to run tests. However, when I test code that uses a shared module (npm linked module via Lerna) it seems that Babel is not correctly applied and I get the following error: SyntaxError: Unexpected token import The structure of my project is like this: - my-project |- shared |- native |- web web and native require the shared module. When I go into the shared directory and run the local tests in Jest everything works fine. If I run Jest tests in the web directory the above error occurs as soon as I include something from