我正在使用锤子进行拖动,并且在加载其他东西时它会变得不稳定,正如此警告消息告诉我的那样.
由于主线程忙,"touchstart"输入事件的处理延迟了X ms.考虑将事件处理程序标记为"被动"以使页面更具响应性.
所以我试着像这样向听众添加"被动"
Hammer(element[0]).on("touchstart", function(ev) {
// stuff
}, {
passive: true
});
Run Code Online (Sandbox Code Playgroud)
但我仍然收到这个警告.
最近我开始在Nodejs上使用MongoDB和Mongoose.
当我使用带有$or条件和_id字段的Model.find方法时,Mongoose无法正常工作.
这不起作用:
User.find({
$or: [
{ '_id': param },
{ 'name': param },
{ 'nickname': param }
]
}, function(err, docs) {
if(!err) res.send(docs);
});
Run Code Online (Sandbox Code Playgroud)
顺便说一句,如果我删除'_id'部分,这就行了!
User.find({
$or: [
{ 'name': param },
{ 'nickname': param }
]
}, function(err, docs) {
if(!err) res.send(docs);
});
Run Code Online (Sandbox Code Playgroud)
而在MongoDB shell中,两者都能正常工作.
在Observables forkJoin文档中,它说args可以是一个数组,但它没有列出这样做的例子:
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/forkjoin.md
我尝试过类似于我列出的功能(如下所示)但是想出了一个错误:
:3000/angular2/src/platform/browser/browser_adapter.js:76
EXCEPTION: TypeError: Observable_1.Observable.forkJoin is not a function
Run Code Online (Sandbox Code Playgroud)
我的功能的剪切版本如下:
processStuff( inputObject ) {
let _self = this;
return new Observable(function(observer) {
let observableBatch = [];
inputObject.forEach(function(componentarray, key) {
observableBatch.push(_self.http.get(key + '.json').map((res: Response) => res.json()));
});
Observable.forkJoin(
observableBatch
// );
).subscribe(() => {
observer.next();
observer.complete();
});
});
}
Run Code Online (Sandbox Code Playgroud)
我的问题的根与循环结束有关,然后按此处的要求继续:Angular2 Observable - 如何在循环之前等待循环中的所有函数调用结束?
但我还没有完全掌握forkJoin与数组的正确用法以及正确的语法.
我非常感谢您提供的帮助.
thirdFunction() {
let _self = this;
return Observable.create((observer) => {
// return new Observable(function(observer) {
...
observer.next(responseargs);
observer.complete();
});
}
processStuff(inputObject) …Run Code Online (Sandbox Code Playgroud) <div class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如何更改bootstrap中的默认模态位置,我应该在哪里编辑以更改默认位置.
众所周知,find()返回一个结果数组,findOne()只返回一个简单的对象.
使用Angular,这会产生巨大的差异.{{myresult[0].name}}我可以简单地写一下,而不是去{{myresult.name}}.
我发现$lookup聚合管道中的方法返回结果数组而不是单个对象.
例如,我有两个收藏:
users 采集:
[{
"firstName": "John",
"lastName": "Smith",
"country": 123
}, {
"firstName": "Luke",
"lastName": "Jones",
"country": 321
}]
Run Code Online (Sandbox Code Playgroud)
countries 采集:
[{
"name": "Australia",
"code": "AU",
"_id": 123
}, {
"name": "New Zealand",
"code": "NZ",
"_id": 321
}]
Run Code Online (Sandbox Code Playgroud)
我的总计$lookup:
db.users.aggregate([{
$project: {
"fullName": {
$concat: ["$firstName", " ", "$lastName"]
},
"country": "$country"
}
}, {
$lookup: {
from: "countries",
localField: "country",
foreignField: "_id",
as: "country" …Run Code Online (Sandbox Code Playgroud) 我使用以下内容通过Multer将文件上传到目录.它工作得很好,但我需要在上传后执行一些操作,这些操作需要我刚刚发布到"upload"目录的文件名.如何获取刚刚发布的文件的名称?
// Multer storage options
var storage = multer.diskStorage({
destination: function(req, file, cb) {
cb(null, 'upload/');
},
filename: function(req, file, cb) {
cb(null, file.originalname + '-' + Date.now() + '.pdf');
}
});
var upload = multer({ storage: storage });
app.post('/multer', upload.single('file'), function(req, res) {
// Need full filename created here
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用角度材料2在我的网站上显示图标,但我有点困惑.
这是它应该如何工作,从材料2的github repo中的演示:
https://github.com/angular/material2/blob/master/src/demo-app/icon/icon-demo.ts
我一直在尝试使用它,但根本没有显示任何图标.
我就是这样设置的:
app.component.ts
import {MdIcon, MdIconRegistry} from '@angular2-material/icon/icon';
@Component({
...
encapsulation: ViewEncapsulation.None,
viewProviders: [MdIconRegistry],
directives: [MdIcon],
})
export class MyComponent{
constructor(private router: Router,
private JwtService:JwtService,
mdIconRegistry: MdIconRegistry){
mdIconRegistry.addSvgIconSetInNamespace('core', 'fonts/core-icon-set.svg')
}
}
Run Code Online (Sandbox Code Playgroud)
和模板..
<md-icon>home</md-icon>
Run Code Online (Sandbox Code Playgroud)
页面加载时没有错误,但没有显示图标.什么可能出错?
我有一个网址,我正在尝试获取id,但它没有工作req.params也不是req.query
app.get('/test/:uid', function testfn(req, res, next) {
debug('uid', req.params.uid); // gives :uid
debug('uid', req.query.uid); // gives undefined
});
Run Code Online (Sandbox Code Playgroud)
我正在做这样的ajax调用
$(document).on('click', 'a.testlink', function(e) {
$.ajax({
type: "GET",
url: '/test/:uid',
success: function(var) {
console.log('success');
},
error: function() {
alert('Error occured');
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
我正在使用
app.use(express.json());
app.use(express.urlencoded());
Run Code Online (Sandbox Code Playgroud)
而不是身体解析器
我正在尝试在我的(cordova)Android应用程序中创建一个身份验证机制,允许我的用户使用密码和用户名登录,或允许他们扫描他们的手指以便登录.
如何验证在客户端,服务器端注册的指纹?这甚至可以使用Cordova吗?我尝试将手指扫描的结果传输到我的服务器:这看起来像:
FingerprintAuth.isAvailable(function(result) {
if (result.isAvailable) {
if(result.hasEnrolledFingerprints){
FingerprintAuth.show({
clientId: client_id,
clientSecret: client_secret
}, function (result) {
alert(JSON.stringify(result));
$http.post('http://192.168.149.33:3000/authorize', result).then(
function(response) {}
);
if (result.withFingerprint) {
$scope.$parent.loggedIn = true;
alert("Successfully authenticated using a fingerprint");
$location.path( "/home" );
} else if (result.withPassword) {
alert("Authenticated with backup password");
}
}, function(error) {
console.log(error); // "Fingerprint authentication not available"
});
} else {
alert("Fingerprint auth available, but no fingerprint registered on the device");
}
}
}, function(message) {
alert("Cannot detect fingerprint device : …Run Code Online (Sandbox Code Playgroud) 您好我有这个架构(称为schema.js):
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var RoomSchema = new Schema({
name: { type: String, required: true, index: { unique: true } },
people: { type: Number, required: true },
childrens: {type: Number, required: true},
total: {type: Number, required: true}
});
var Room = mongoose.model('Room', RoomSchema);
var AvSchema = new Schema({
roomId: {type: Schema.Types.ObjectId, ref: 'Room'},
people: { type: Number, required: true },
childrens: {type: Number, required: true},
total: {type: Number, required: true}
});
var Av = mongoose.model('Av', …Run Code Online (Sandbox Code Playgroud)