假设有人在一个文件中编写了一个这样的方法,该文件app.js试图通过一个不存在的url来执行XHR请求:
app.controller('MainCtrl', function($scope,$http) {
$scope.send = function() {
$http.get('http://run.plnkr.co/thisIs404');
};
});
Run Code Online (Sandbox Code Playgroud)
我可以http://run.plnkr.co/thisis404在控制台和网络面板中看到有关URL的错误:

要调试这个我想快速找到在源中进行此XHR调用的位置(即查找app.js文件):
所以我启用了chrome dev工具:
调试器实际上在XHR请求上停止,但调用堆栈仅显示对angular.js"核心"文件的引用 :没有对app.js 任何地方的引用.

我尝试使用铬36和铬35.只有解决方案:在整个代码库中搜索错误的URL(在某些情况下可能很难).
app.js堆栈中的somwhere?app.js从控制台错误轻松追踪此文件?使用vanilla XHR请求(即没有角度),XHR调试调用堆栈显示XHR调用app.js(在这种情况下更容易调试):

这里有完整的例子:http://plnkr.co/edit/lnCRpv?p = preview
[编辑]我被问到:Angular.js在我的测试中没有缩小.
javascript ajax asynchronous google-chrome-devtools angularjs
鉴于我有2个路径呈现相同的组件,我如何避免重复这样的路由配置:
<Route path="/path1" component={MyComp} />
<Route path="/path2" component={MyComp} />
Run Code Online (Sandbox Code Playgroud) 我正在构建一个带有服务器端渲染 (SSR) 的单页 Web 应用程序 (SPA)。
我们有一个节点后端 API,它在 SSR 期间从节点服务器调用,在初始渲染后从浏览器调用。
我想编写 e2e 测试来配置 API 响应(如 with nock)并同时处理浏览器调用和 SSR 服务器调用。一些伪代码:
it('loads some page (SSR mode)', () => {
mockAPI.response('/some-path', {text: "some text"}); // here i configure the mock server response
browser.load('/some-other-page'); // hit server for SSR response
expect(myPage).toContain('some text');
})
it('loads some other page (SPA mode)', () => {
mockAPI.response('/some-path', {text: "some other text"}); // here i configure another response for the same call
browser.click('#some-link'); // loads another page client …Run Code Online (Sandbox Code Playgroud) 如何从包含特定文本的转发器中搜索元素?
我尝试过这样的事情:
element(by.repeater('item in array')).all(by.cssContainingText('.xyz','my item title')); // only gets the first element
Run Code Online (Sandbox Code Playgroud)
我可以自己搜索使用.then,element.all但我想知道它是否存在更简单的东西,cssContainingText但对于中继器:
element(by.repeaterContainingText('item in array','my item title'))
Run Code Online (Sandbox Code Playgroud)
或者像这样链接的元素:
element.all(by.repeater('item in array')).element(by.cssContainingText('.xyz','my item title'));
Run Code Online (Sandbox Code Playgroud)
带过滤器的解决方案(但速度很慢)
element.all(by.repeater('item in array')).filter(function(elem){
return elem.getText().then(function(text){
return text.indexOf('my item title') > -1;
});
}).then(function(filteredElements) {
return filteredElements[0];
})
Run Code Online (Sandbox Code Playgroud) 我正在寻找一个javascript客户端lib来处理像这样的ajax或websocket请求队列:
理想情况下:
我找不到这样的东西.我应该自己使用localstorage构建一个,例如window.navigator.onLine和socket.io还是已经有一些用于此目的的lib?
谢谢.
我一直读到我应该使用 redux-thunk 或 redux-saga 来处理副作用。为什么不简单地使用这样的动作创建者来分派多个动作:
function loadProductActionCreator(dispatch) {
dispatch({
type: 'load_product',
})
fetch('api/product').then(
function (r) {
return r.json();
}
)
.then(function (res) {
dispatch({
type: 'loaded_product',
data: res
})
})
}
Run Code Online (Sandbox Code Playgroud)
我试过了,它奏效了(完整的代码)。所以我想一定有一些我不知道的不便之处。
如何翻译涉及带有样式组件的兄弟选择器的规则?(我认为它还涉及通过生成的类名称的其他样式的样式)
const Pane = styled.div`
& > .subItem + .subItem {
margin-top:10px;
}
`
Run Code Online (Sandbox Code Playgroud) display我可以使用imagemagick CLI实用程序
display *.png
Run Code Online (Sandbox Code Playgroud)
但是它仅显示第一张图像,而现在不显示如何在图像之间循环。有键盘快捷键吗?我尝试了箭头pgup / pgdwn等,但没有成功,man并且没有提供任何有关此的信息。
使用eZ Publish 2014.11,我想在objectrelationlist字段上过滤搜索结果.
我使用这段代码(我删除了与objectrelatiolist字段无关的所有部分):
$query->query = new Criterion\LogicalAnd(
array(
// ...
new Criterion\Field( 'myField', Criterion\Operator::EQ, my_value ),
// ...
)
);
Run Code Online (Sandbox Code Playgroud)
根据分析器,生成的查询看起来像这样(我删除了与objectrelatiolist字段无关的所有部分):
SELECT
-- ...
AND `ezcontentobject`.`id` IN (
SELECT
`contentobject_id`
FROM
`ezcontentobject_attribute`
WHERE
(
-- ...
AND (
`contentclassattribute_id` IN ('342')
AND `sort_key_string` = my_value
)
)
)
-- ...
Run Code Online (Sandbox Code Playgroud)
对于字段行,数据库sort_key_string中的Apparenty为空(尽管data_text字段中显示现有关系):
*************************** 385. row ***************************
attribute_original_id: 0
contentclassattribute_id: 342
contentobject_id: 137
data_float: 0
data_int: NULL
data_text: <?xml version="1.0" encoding="utf-8"?>
<related-objects><relation-list><relation-item priority="1" contentobject-id="67" contentobject-version="1" node-id="69" parent-node-id="2" contentclass-id="43" contentclass-identifier="theme" …Run Code Online (Sandbox Code Playgroud) javascript ×3
reactjs ×3
ajax ×2
angularjs ×1
asynchronous ×1
css ×1
cypress ×1
ezpublish ×1
imagemagick ×1
nock ×1
node.js ×1
protractor ×1
react-redux ×1
react-router ×1
redux ×1
redux-saga ×1
redux-thunk ×1
socket.io ×1
testing ×1
websocket ×1