我尝试让CasperJS实现以下目标:
我得到了一些工作代码,但我不明白CasperJS是如何经历事件序列的.
例如,在下面的代码示例中,CasperJS尝试处理第2步,并抛出"ReferenceError:找不到变量:formDate",而第1步由于某种原因根本不执行.
我的推理有什么问题?
在我看来,while循环以与casper.then方法不同的速度执行.
casper.start();
casper.thenOpen('http://www.example.com', function() {
this.echo(this.getTitle());
});
casper.then(function() {
var start = new Date('2013-01-01T00:00:00');
var end = new Date('2013-01-31T00:00:00');
while(start < end) {
// step 1: define formDate
casper.then(function() {
var formDate = start.getFullYear()+"-"+("0" + (start.getMonth() + 1)).slice(-2) +"-"+("0" + start.getDate()).slice(-2) ;
casper.echo(formDate);
});
// Step 2: open the page and download the file
casper.thenOpen('http://www.example.com/' + formDate, function() {
var url = this.getElementAttribute('div#pdffulllink a.pdf', 'href');
this.echo(url);
this.download(url, 'Downloaded_' + …Run Code Online (Sandbox Code Playgroud) 我正在构建一个 CSS 网格布局,不知何故我无法获得“自动”值来调整行高的大小。
项目保持最小高度为 1fr,即使它们的内容小到足以让它们缩小。
这是一个解释问题的代码示例 - 您也可以在https://codepen.io/16kbit/pen/RJbMWM上查看
section {
display: grid;
grid-template-areas: "one top" "one bottom";
align-items: start;
border: 1px solid hotpink;
}
article {
border: 1px solid green;
}
#one {
grid-area: one;
}
#top {
grid-area: top;
}
#bottom {
grid-area: bottom;
background: yellow;
}Run Code Online (Sandbox Code Playgroud)
<section>
<article id=one>
<h1>One</h1>
<p>Lorem cool dolizzle sit amizzle, dope sizzle elizzle. Nullam shiznit velizzle, get down get down volutpizzle, suscipizzle quizzle, dizzle mammasay mammasa mamma oo sa, arcu. Pellentesque …Run Code Online (Sandbox Code Playgroud)