草庐IT

Path_and_regular_expression_mappi

全部标签

javascript - 在 jQuery 选择器中混合逻辑 AND 和 OR

我必须过滤包含两个关键数据属性的项目列表:Freedom类别标签按类别过滤应该是逻辑OR但按标签过滤应该是逻辑AND。使用这两者之一进行过滤不是问题。我申请了,例如:$(collection).filter('li[data-tags*="tag-50-eot"][data-tags*="tag-51-eot"]');按标签过滤。或者:$(collection).filter('[data-category="1"],[data-category="2"]);按类别过滤。这很好用。但是,我找不到一种方法将这两个选择器组合成一个我可以传递给filter()函数的查询,并且链接两个filt

javascript - Karma + Jasmine( Angular Testing ): Where should I define mock classes and test variables?

让我们来看下面的例子:constlistDefinition:any={module:"module",service:"service",listname:"listname"};@Component(...)classMockTreeExpanderComponentextendsTreeExpanderComponent{...}classMockListConfigurationsServiceextendsListConfigurationsService{...}describe('ColumnsListConfigurationsComponentTestcases',(

javascript - 如何正确设置 Node、Express 和 Angular2

我正在尝试使用Node、Express、Angular2(数据库、MongoDB或SQL)设置工作区但我不确定如何正确设置组合。目前我的文件结构是这样的,打算把front-end放在public文件夹下。──package.json├──public├──routes│  └──test.js├──server.js└──views到目前为止,我的server.js看起来像这样varexpress=require('express');varmysql=require('mysql');varcookieParser=require('cookie-parser');varbodyPa

javascript - JS : Get inner function arguments in asynchronous functions and execute callback

我尝试编写返回异步函数的所有结果的函数,并执行一个回调,将其插入数组并记录每个异步函数的结果。作为一个服务员,当所有的菜都吃完了就端上来。我不明白如何获得应该作为结果返回的子参数。任务代码和我不工作的解决方案如下:任务:vardishOne=function(child){setTimeout(function(){child('soup');},1000);};vardishTwo=function(child){setTimeout(function(){child('dessert');},1500);};waiter([dishOne,dishTwo],function(res

javascript - 无法访问 Express/NodeJS 中的 req.session 变量

我见过这个问题的许多变体,但似乎没有一个能解决我的问题。我正在尝试使用Express设置一个Node.js服务器。这是我的服务器配置:varexpress=require('express'),RedisStore=require('connect-redis')(express);varapp=express();app.use(express.urlencoded());app.use(express.json());app.use(express.cookieParser());app.use(express.session({store:newRedisStore(),secr

javascript - Jade : load external javascript and call function

我正在学习Express/Node/Jade,现在我想在Jade文件中包含一个来自公共(public)文件夹的javascript文件,只用于该页面。例如,在jade文件中我输入:script(src='/javascripts/test.js')在test.js里面我有一个函数functioncheck_test(){return"It'sworking!"}然后我尝试通过以下方式调用Jade中的函数-vartest_response=check_test()比我得到的错误说“undefinedisnotafunction”和test.js根本没有加载。显然Jade不会加载文件,它们

javascript - Node.js 事件发射器 : How to bind a class context to the event listener and then remove this listener

有没有办法在事件监听器方法中访问类上下文并有可能删除监听器?示例1:import{EventEmitter}from"events";exportdefaultclassEventsExample1{privateemitter:EventEmitter;constructor(privatetext:string){this.emitter=newEventEmitter();this.emitter.addListener("test",this.handleTestEvent);this.emitter.emit("test");}publicdispose(){this.emi

javascript - Node.js & Express.js 字体区分

我在Node.js和Express.js上随意开发了示例。在启动下面显示的每个的example.js之后,我遇到了它们之间的字体差异。即使我知道Express是Node的框架,但我找不到任何地方为什么排版会发生变化。Node.js:consthttp=require('http');consthostname='127.0.0.1';constport=3000;constserver=http.createServer((req,res)=>{res.statusCode=200;res.setHeader('Content-Type','text/plain');res.end('

javascript - 使用 express nodejs 获取此错误 auth/operation-not-supported-in-this-environment

我在我的项目中使用Firebase,但在使用google凭据登录时出现此错误auth/operation-not-supported-in-this-environment。.hbs文件代码脚本代码functionloginWithGoogle(event){$.ajax({url:"/session/google/login",type:"POST"}).done(function(data){error=JSON.stringify(data);console.log(error);M.toast({html:error})});}express代码router.post('/se

javascript - 让 grun-express 重新启动更改

我正在尝试使用grunt-express和grunt-watch。我希望通过更改服务器文件重新加载服务器。这是我得到的。Gruntfile.jsvarpath=require('path');module.exports=function(grunt){grunt.initConfig({express:{options:{port:8000},load:{server:path.resolve('./app')}},watch:{express:{files:['app.js'],tasks:['express:load']}}});grunt.loadNpmTasks('grunt