草庐IT

babel-watch

全部标签

javascript - jsx --watch 将 jsx 语法转换为小写 "react"而不是大写 "React"

我在这里松散地关注facebooksReact教程,http://facebook.github.io/react/docs/getting-started.html,但我将其应用于不同的html文件。这是我的html文件,基于React入门工具包:HelloReact我安装了react-tools,现在当我运行“jsx--watchsrc/build/”它正在转换这个片段:varCommentBox=React.createClass({render:function(){return(Hello,world!IamaCommentBox.);}});React.renderComp

javascript - 在 Controller 中使用 `this` 作用域时使用 $scope.$watch

我的Angular应用程序中有一个Controller:(function(angular){functionMyController(){this.name='Dave';//Iwanttohavecodelikethis:/*$scope.$watch('name',function(newValue,oldValue){console.log(oldValue,"changedto",newValue);});*/}window.myApp=angular.module('myApp',[]).controller('MyController',[MyController]);}

javascript - 使用 Babel CLI 提取器提取 Javascript gettext 消息

据说hereBabel可以提取Python和Javascript文件的gettext消息。Babelcomeswithafewbuiltinextractors:python(whichextractsmessagesfromPythonsourcefiles),javascript,andignore(whichextractsnothing).命令行提取器已记录here-但没有使用示例。也在samepointer上面提到了用于提取的配置文件,但没有太多展开。当我在包含js文件的目录上运行提取器的基本命令时,我只生成了.POheader,但没有消息。$pybabelextract/p

javascript - angular js 在 watch 语句中恢复范围属性的更改

我有一个选择框,当它发生变化时会触发一个httpPUT。html:js:$scope.$watch('color',function(newValue,oldValue){$http.put('...',{color:newValue})});问题是,如果http请求因任何原因失败,我希望选择框恢复到它以前的值。$scope.$watch('color',function(newValue,oldValue){req=$http.put('...',{color:newValue})req.error(function(){$scope.color=oldValue//willprob

javascript - $scope.$watch in Angular 在 Ionic/Cordova 中不起作用

我正在使用IonicFramework构建应用程序我现在想为此创建一些开关(基本上是花哨的复选框)。当有人按下开关时,我想将其发送到服务器,因此我首先trycatch开关更改事件。在基本的Angular安装中,我在html()和$watch中使用一个简单的复选框进行了尝试。在我的Controller中像这样:$scope.$watch('theswitch',function(){console.log('theswitchchanged');if($scope.boel){console.log('theswitchisTRUE');}else{console.log('theswi

javascript - Angular : Watch Service for data changes?

我有一个定义如下的服务:appServices.service('SharedData',function(){vardata={};functionsetContacts(contacts){data.contacts=contacts;};functiongetContacts(){returndata.contacts;};return{setContacts:setContacts,getContacts:getContacts};});在另一个Controller中,我按如下方式访问数据:$scope.contacts=SharedData.getContacts();一切都

javascript - 使用 Babel.js 将 ES6 箭头函数编译为 Es5

在Mozilla文档中查看ES6箭头函数的文档时,我了解到箭头函数应用严格模式的所有规则,除了在link中描述的规则。varf=()=>{'usestrict';returnthis};varg=function(){'usestrict';returnthis;}console.log(f());//printsWindowconsole.log(g());//printsundefined//wecantestthisinfirefox!但是,Babel.js将箭头函数代码转换为ES5代码,返回undefined而不是Window(demolink)"usestrict";setT

javascript - Angular $watch 不工作

我在我的Controller上使用了两个$watches来观察这两个对象:$scope.gastos={name:"Gastosmensuales",data:[0,0,0,0,0,0,0,0,0,0,0,0],labels:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]};$scope.ganancias={name:"Gananciasmensuales",data:[0,0,0,0,0,0,0,0,0

javascript - "export default from"不适用于 Babel React

我使用react来构建我的组件库。我需要一个index.js来将所有组件导入一个地方。像这样:MyComponents/Button.jsLabel.jsindex.js在index.js中,我接下来尝试做的是://thisexportnothingexport{default}from'./Button';//thistellsmeaboutsyntaxerrorexportdefaultfrom'./Button';我发现只有这个解决方案有效importButtonfrom'./Button';exportdefaultButton;但我发现一些React组件库使用我上面提到的语法

javascript - webpack.config.babel.js中使用 'import'报错

(function(exports,require,module,__filename,__dirname){importpathfrom'path'^^^^^^SyntaxError:Unexpectedtokenimport当我使用webpack-dev-server--hot时出现此错误。出现这种情况好像是因为它无法读取import或者webpack不支持import。我尝试使用babel-register但它不起作用。有什么办法可以解决这个问题吗?请引用下面的代码。webpack.config.babel.jsimportpathfrom'path'importwebpackf