草庐IT

T_FUNCTION

全部标签

Javascript Split Function 和 Jquery 不能一起工作

需要解析URL的Get变量。我制作了一个document.location的jQuery对象,然后使用attr函数获取搜索属性以获取所有变量。但是当我在它上面使用split函数并在使用each()之后它给出错误,指出该对象没有方法each。TypeError:Object[objectArray]hasnomethod'each'代码是:$(document.location).attr('search').split('&').each()我也曾尝试在第一个函数中使用搜索属性,但它不允许这样做,即$(document.location.search)给出错误。我还检查了split函数

javascript - “require”关键字在 Node Red Function Node 中不起作用

Node红色功能Node的第一行是varmoment=require('moment-timezone');...我正在尝试为传感器数据建立时区正确的日期/时间戳。此Node运行时出现以下错误;ReferenceError:requireisnotdefined(line1,col14)顺便说一下,这个函数有其他JavaScript总是完美运行。我的Package.json没有错误,我添加了“moment-timezone”:“0.5.3”。我从一点点或研究中了解到我需要向settings.js文件添加一些内容,但是,我需要一些关于添加内容的指导,以便识别“require”。

javascript - typescript : Unexpected token; 'constructor, function, accessor or variable'

我用类型脚本编写了以下类。当我编译它时,它会出错说"src\main\MqttClientWrapper.ts(24,2):错误TS1068:意外的token。一个构造或者,需要方法、访问器或属性。”。下面是我的代码。varmqtt:any=require('mqtt');exportinterfaceIWillMessage{topic:string;payload:string;qos:number;retain:string;}exportinterfaceIMessageReceivedCallBack{onMessageReceived(message:string);}ex

javascript - Node.js 类型错误 : Object function Object() { [native code] } has no method 'assign'

每当我执行我的程序时,我都会收到以下TypeError:/home/Node-Project/node_modules/sentiment/lib/index.js:31afinn=Object.assign(afinn,inject);^TypeError:ObjectfunctionObject(){[nativecode]}hasnomethod'assign'atmodule.exports(/home/Node-Project/node_modules/sentiment/lib/index.js:31:24)atEventEmitter.(/home/Node-Projec

javascript - 未捕获的 ReferenceError : (function) is not defined at HTMLButtonElement. onclick

我有一个搜索表单,我试图让它在页面底部输出结果而无需重新加载。TypeFirstName我希望在单击按钮时在下方显示搜索结果,使用Ajax调用另一个脚本。我不断收到错误消息:“未捕获的ReferenceError:搜索输出未在HTMLButtonElement.onclick中定义这是我的javascript(使用jquery):$(document).ready(function(){functionsearchoutput(){if($(".search-field").val().length>5){//onlyshowsresultswhenmorethan5character

javascript - react 性能 : bind vs anonymous function

我想知道在React组件中使用bind和匿名函数之间是否存在性能差异。具体来说,以下一项是否比另一项更高效?constMyComponent=({myHandler})=>{...return(helloworld);}constMyComponent=({myHandler})=>{...return({myHandler(this,foo,bar)}...>helloworld);}这个问题与possibleduplicate不同,因为possibleduplicate问题的答案集中在内存占用上。 最佳答案 首先,您设置问题的方

javascript - 类型错误 [ERR_INVALID_CALLBACK] : Callback must be a function

我想制作一个脚本来向angularwebpack应用程序添加新规则,如下所示。有时代码会部分执行,有时会出错。constfs=require('fs');constcommonCliConfig='node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js';constpug_rule="\n{test:/\\.pug$/,loader:['raw-loader','pug-html-loader']},";varconfigText="";fs.re

javascript - 为什么使用 Function.prototype.bind 而不是 Function.prototype.call?

myFunction.call(thisArg,arg1,arg2...)我的理解是,当我使用call方法并提供thisArg时,函数中的this值设置为我传入的对象.myFunction.bind(thisArg,arg1,arg2...)而另一方面,bind方法返回一个新函数,新函数的this上下文设置为我传入的对象。但我不明白的是为什么要使用bind而不是call。如果我只想更改this的上下文,call对我来说就足够了。那为什么要在IE8及以下浏览器中中断时使用bind。那么,与call相比,什么时候使用bind会更好? 最佳答案

javascript - react .js : onClick function from child to parent

我用了this以文章为例(React方式),但它对我不起作用。请指出我的错误,因为我不明白哪里出了问题。这是我看到的错误:UncaughtTypeError:this.props.onClickisnotafunction这是我的代码://PARENTvarSendDocModal=React.createClass({getInitialState:function(){return{tagList:[]};},render:function(){return({this.state.tagList.map(function(item){return()})})},HandleRem

javascript - 在 Firebase 云函数中包含异步函数 (eslint "Parsing error: Unexpected token function")

问题如何将async辅助方法添加到CloudFunctionsindex.js文件中?在将fs.writefile转换为Promise时,需要一个async函数才能使用await,如本文所述StackOverflow帖子:fs.writeFileinapromise,asynchronous-synchronousstuff.但是,lint不赞成在exports函数之外向index.js文件添加额外的方法。错误第84行引用辅助函数asyncfunctionwriteFile。Users/adamhurwitz/coinverse/coinverse-cloud-functions/fu