我有一个上下文菜单,通过按热键ctrl +菜单手动显示.因此我使用此功能:
ContextMenu.IsOpen = true;
Run Code Online (Sandbox Code Playgroud)
我在主窗口中调用它.但它有一些奇怪的效果.
我的菜单就是这个:
<Window.ContextMenu>
<ContextMenu Placement="Center">
<MenuItem IsCheckable="False" Name="item2" Click="MenuItem_Click" Header="{DynamicResource countDownNotificationOn}"/>
</ContextMenu>
</Window.ContextMenu>
Run Code Online (Sandbox Code Playgroud)
使用上面的xaml放置也不起作用.因此我将窗口设置为
ContextMenuService.Placement="Center"
Run Code Online (Sandbox Code Playgroud)
但是不起作用.
我在iPhone上的离子应用程序有问题.Ionic将此写入index.html:
<iframe src="gap://ready" style="display:none;">...</iframe>
Run Code Online (Sandbox Code Playgroud)
应用程序的控制台输出每秒循环此错误大约40次:
Refused to load gap://ready because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy.
Run Code Online (Sandbox Code Playgroud)
我猜每次使用angular的dirtycheck工作时,都会抛出此错误.iframe来自何处以及如何摆脱iframe和错误?
我读了一些其他问题和帖子,但我找不到应用.setMaxListeners(0)的位置.我正在使用一个简单的websocket-server,它提出了错误:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Socket.EventEmitter.addListener (events.js:160:15)
at Socket.Readable.on (_stream_readable.js:689:33)
at XHRPolling.Transport.setHandlers (D:\nodeJS\host\node_modules\socket.io\lib\transport.js:116:15)
at XHRPolling.HTTPPolling.setHandlers (D:\nodeJS\host\node_modules\socket.io\lib\transports\http-polling.js:53:39)
at XHRPolling.Transport.handleRequest (D:\nodeJS\host\node_modules\socket.io\lib\transport.js:70:10)
at XHRPolling.HTTPTransport.handleRequest (D:\nodeJS\host\node_modules\socket.io\lib\transports\http.js:84:39)
at XHRPolling.HTTPPolling.handleRequest (D:\nodeJS\host\node_modules\socket.io\lib\transports\http-polling.js:73:41)
at XHRPolling.Transport (D:\nodeJS\host\node_modules\socket.io\lib\transport.js:31:8)
at XHRPolling.HTTPTransport (D:\nodeJS\host\node_modules\socket.io\lib\transports\http.js:29:13)
at XHRPolling.HTTPPolling (D:\nodeJS\host\node_modules\socket.io\lib\transports\http-polling.js:27:17)
Run Code Online (Sandbox Code Playgroud)
我用这种方式实例化路由器:
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app, { log: false })
, fs = require('fs');
app.listen(8070);
Run Code Online (Sandbox Code Playgroud)
然后我正在侦听插入请求:
io.sockets.on('connection', function (socket) {
socket.on('createTake', function(data){...}
});
Run Code Online (Sandbox Code Playgroud)
我在哪里可以应用MaxListeners?
我已经尝试过了:
io.sockets.on(...).setMaxListeners(0);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我想测试一个包含ajax请求的函数.测试应该等待ajax-request成功/失败.运行测试不起作用,因为它现在不会等待.
这个我想测试一下:
this.requestServerBoxId = function()
{
//ajax-request
$.ajax({
url: this.host_addr+"/?getid="+this.name,
type: 'POST',
data: {_data:this._data},
success: function(data) {
return IdSuccess(data);
},
error: function(data){
return false;
}
});
}
function IdSuccess(data){
if(typeof data != undefined)
return true;
return false;
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
it("should call a function after ajax-success", function(){
expect(this.Process.requestServerBoxId()).toBe(true);
});
Run Code Online (Sandbox Code Playgroud)
我试过间谍,但我猜我错了:
spyOn($, 'ajax' ).and.returnValue(123);
Run Code Online (Sandbox Code Playgroud)
我希望每次ajax请求发出时,这个间谍都会返回123.但它不起作用.
我有一个带有五个单元的jQuery Mobile Grid系统.我想让这些细胞的内容与细胞中间对齐.
我试着添加:
<div style="vertical-align:middle;">text</div>
Run Code Online (Sandbox Code Playgroud)
但这没效果.
也:
<div style="top:50%;">text</div>
Run Code Online (Sandbox Code Playgroud)
没工作.
我创造了一个小提琴来检查它.我有什么想法我做错了吗?
如何导航到以前的状态并返回浏览器历史记录.
我记得AngularJS支持这个:
$window.history.back();
Run Code Online (Sandbox Code Playgroud)
React支持这个:
import { browserHistory } from 'react-router'
browserHistory.goBack();
Run Code Online (Sandbox Code Playgroud)
如何在Angular 2> = v2.1.0中返回和以前的浏览器历史记录
是否有可能将函数注册到动画结束时调用的Animated Usercontroll?
我有一个Usercontroll-Animation,我首先调用.BeginAnimation(propdp,animation);
如何在动画结束时调用另一个函数?
我试着让离子滑动盒从某个指数开始.
slidebox-controller:
$ionicSlideBoxDelegate.slide(index);
Run Code Online (Sandbox Code Playgroud)
slide-box-temp:
<ion-slide ng-repeat="pic in pictures"><div>...</div></ion-slide>
Run Code Online (Sandbox Code Playgroud)
这不起作用.也许是因为还没有渲染幻灯片盒.
还有另一种方法可以在某个索引处启动幻灯片吗?
我有一系列的承诺,我使用catch捕获错误.
this.load()
.then(self.initialize)
.then(self.close)
.catch(function(error){
//error-handling
})
Run Code Online (Sandbox Code Playgroud)
如果链完成没有拒绝,会调用什么函数?我终于使用了,但是如果发生错误也会调用它.我想在catch函数之后调用一个函数,只有在没有承诺被拒绝的情况下才调用它.
我正在将node.js与q - 模块一起使用.
我想在xCode中验证我的cordova项目.构建过程成功了.所有图标都显示在测试设备和模拟器上.验证器显示此问题:
Invalid Image Path - No image found at the path referenced under key
'CFBundleIconFile':'icon.png'
Run Code Online (Sandbox Code Playgroud)
我在目标信息中找不到名为"CFBundleIconFile"的键.这个密钥集在哪里?我该如何解决这个问题?
我有一个函数默认返回null,另一个值由condition.
var getName = function(boxid){
var boxes = localStorage.getItem("boxes");
if((boxes != "" )&& (typeof boxes != "undefined") &&( boxes != null))
{
boxes = JSON.parse(boxes);
boxes.forEach(function(box){
if(box.id == boxid)
{
console.log("box.name: "+ box.name+ " boxid: "+ box.id+ " : "+ boxid);
return box.name;
}
});
}
return null;
};
Run Code Online (Sandbox Code Playgroud)
找到正确的数组条目.但返回statemant不返回它,它被忽略了.
我在一个名为pown的集合文档中有一个数组.
{
_id: 123..,
name: pupies,
pups:[ {name: pup1, location: somewhere}, {name: pup2, ...}]
}
Run Code Online (Sandbox Code Playgroud)
现在,使用我的rest-service的用户将整个第一个条目作为put请求发送:
{name: pup1, location: inTown}
Run Code Online (Sandbox Code Playgroud)
之后我想在我的数据库中更新这个元素.
所以我试过这个:
var updatedPup = req.body;
var searchQuery = {
_id : 123...,
pups : { name : req.body.name }
}
var updateQuery = {
$set: {'pups': updatedPup }
}
db.pown.update(searchQuery, updateQuery, function(err, data){ ... }
Run Code Online (Sandbox Code Playgroud)
不幸的是,它没有更新anythig.有谁知道如何更新整个数组元素?