jjzjj

test_function

全部标签

javascript - Wicket 口 6 : calling javascript function after page load

这看起来很简单,但我找不到在页面加载后(在扩展WebPage的页面上)如何从wicket调用javascript函数的示例。任何人都可以举例说明如何去做吗? 最佳答案 你可以让javascript为你做这件事window.onload=function(){//dostuffhere}如果您在javascript函数中需要来自您的wicket页面的参数,您可以重写renderHead并在其中添加该函数:@OverridepublicvoidrenderHead(IHeaderResponseresponse){super.rende

Javascript 正则表达式 : test people's name

来自这个问题:javascriptregex:onlyenglishlettersallowed如何对人名进行表情测试?目前它根本不允许名称之间有空格。我需要能够匹配像JohnDoe这样的东西干杯 最佳答案 letresult=/^[a-zA-Z]+$/.test('JohnDoe');console.log(result);在字符类中抛出您需要的任何符号。这就是为什么我说要具体确切地您想要验证的内容。此正则表达式不会考虑重音字符,如果您关心这一点,您最好使用unicode匹配。 关于J

Javascript : onHashchange Test

我正在尝试检查浏览器是否支持onHashChange或者如果不支持则不隐藏一些代码,以这种方式:if(window.onhashchange){...code...}else{...othercode...}我也试过这个:if(typeofwindow.onhashchange==="function"){alert("Supports");}else{alert("Doesn'tSupports");}如Quirksmode所述这应该有效,但是如果我在Safari中的truestate中执行alert比提醒我但Safari不支持onHashChange:S它有什么问题?如果我走的路不

javascript - Unhandled Promise rejection : push. on is not a function

我正在使用Ionic2。我在尝试设置推送通知时收到此Typescrpt错误。我从教程中复制了这个示例代码,所以我希望它能工作。我一定是出了什么问题。任何想法请:UnhandledPromiserejection:push.onisnotafunction;Zone:angular;Task:Promise.then;Value:TypeError:push.onisnotafunctionpush.on('registration',function(data){typescriptimport{Push}from'ionic-native';..pushNotifications()

JavaScript 模式 : Context of Function Call

从一开始我就有大量的JavaScript,函数调用是这样写的:THING.someFunction.call(THING);在我看来,它应该始终等同于:THING.someFunction();这两个调用总是等价的吗?旧版本的JavaScript呢?在我看来,第一行代码中第二个THING的目的是在someFunction中设置上下文(this).但是默认情况下,该函数内的上下文应该已经是THING了,对吧?为了清楚起见,THING的定义如下:varTHING=function(){//privatevarsreturn{//codesomeFunction:function(){//c

javascript - 我不断收到 TypeError : undefined is not a function

在MEAN堆栈应用程序中运行以下代码时,我不断收到上述错误:$scope.completelesson=function(lessonindex,type){//avariablethatwillbeappendedto'level'inordertoaccessthelevelpropertyoftheuservarx=lessonindex+1;varlevel='level'+x;vartoupdate={level:level,type:type,};console.log(toupdate);$http({method:'POST',url:'/users/updatelev

javascript - 良好做法 : How can I ensure a JavaScript constructor has access to mixin functions?

作为RPG游戏后端的一部分,我希望能够对Angular色应用临时效果。这些影响的性质可能有很大差异,但我想保持定义它们的方法非常简单。我将自定义事件处理用作混合:varEvtObject={};$rpg.Event.enable(EvtObject);//Addthe3methodsandsetEvtObject._events={}我想将Auras(临时效果)定义为带有事件处理代码的构造函数:varMyAura=function(any,args){this.group="classification";this.on("tick",function(){});this.on("re

javascript - Angular Directive(指令) : It's possible testing that certain characters are rejected in a keypress event?

我一直在构建一个指令来限制用户按下某些无效字符,在这种情况下,使用keypress事件绑定(bind)到使用我的指令的输入元素。我一直在尝试测试此功能,但我不明白如何实现。我的指令angular.module('gp.rutValidator').directive('gpRutValidator',directive);directive.$inject=['$filter'];functiondirective($filter){varddo={restrict:'A',require:'ngModel',link:linkFn};returnddo;functionlinkFn(

javascript - 如何使用 vue-test-utils 测试 CSS 框架自定义组件

我使用的是BuefyCSS框架,它提供自定义vue-js组件,例如和,我在测试时遇到了问题标签。import{shallowMount,createLocalVue}from'@vue/test-utils'importBInputPracticefrom'../BInputPractice.vue'importBuefyfrom'buefy'constlocalVue=createLocalVue()localVue.use(Buefy)describe('b-inputPractice',()=>{it('updatesthenamedataproperty',()=>{const

javascript - 为什么在 Firefox 中 Function.prototype.func=... 不影响 console.log?

我已经使用Function.prototype.func=...添加了一个函数到Function但在Firefox中它没有被添加console.log:Function.prototype.func=function(){returnthis.toString();};alert(typeofconsole.log.func);//inFF:undefined,inChrome:function这是错误还是有任何原因? 最佳答案 在Firefox中很明显:varfoo=function(){}foo.__proto__==Funct