我需要运行生成器异步(我需要在控制台1,2,3,4,5中导致结果现在我有4,1,2,3,5)任何人都可以帮助我吗?我需要运行任务并等待上一个任务完成后再运行下一个任务.我需要使用(如果可能的话)发电机(或发电机+承诺?)
在这里我的代码
/*jshint esnext: true */
function show(msg) {
var _msg = msg;
setTimeout(function() { console.log(_msg);}, 2000);
}
function show2(msg) {
console.log(msg);
}
var stack = [];
// add some function to stack
stack.push(function() { show(1); });
stack.push(function() { show(2); });
stack.push(function() { show(3); });
stack.push(function() { show2(4); });
stack.push(function() { show(5); });
function* generator1() {
for(var key of stack) {
yield key();
}
}
var gen = generator1();
gen.next();
gen.next();
gen.next();
gen.next();
gen.next();
Run Code Online (Sandbox Code Playgroud) 我很抱歉我的语言,但我不会说英语.
我正在尝试在我的应用程序SSL中实现,但我只有由csr文件创建的valud p7b.我在linux服务器上使用expressjs和node js.我知道如何实施PEM证书
var options = {
key: fs.readFileSync('./private.pem'),
cert: fs.readFileSync('./' + config.ssl[config.mode].cert)
};
server = https.createServer(options, app).listen(3000);
Run Code Online (Sandbox Code Playgroud)
但我不知道如何实施p7b证书,请帮助我
不久前,我安装了 Angular Cli 7 并通过以下方式启动了干净的项目
ng new my-app
Run Code Online (Sandbox Code Playgroud)
我为css选择了预编译器SASS,但是当我编辑文件styles.sass然后不起作用时,我的styles.sass看起来像这样
h1 { color: red }
Run Code Online (Sandbox Code Playgroud)
但 ng serve 显示此消息
编译失败。
./src/styles.sass (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??嵌入!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.sass) 模块构建失败(来自 ./node_modules/sass-loader/lib/loader.js ):
h1 { ^ "h1 {": 预期的 "}" 之后的 CSS 无效,在 /Users/a/Documents/angular-projects/my-app/src/styles.sass 中为 "{"(第 1 行,第 5 列)
如何解决?为什么会这样?
在重新调整浏览器大小时,我的输入会增加和减少。如何更改相同的字体大小?没有js可以吗?font-size 应该是 100% 输入高度。
http://jsfiddle.net/krLf0cbc/7/
<div class="container">
<div class="inner">
<input class="input"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和CSS
.container {
width: 100%;
}
.inner {
position: relative;
}
.input
{
position: absolute;
padding-bottom: 10%;
width:100%;
}
Run Code Online (Sandbox Code Playgroud) 今天我写了这段代码:
(function (window) {
'use strict';
function ViewPort() {
var getSize = function () {
var e = window,
a = 'inner';
if (!('innerWidth' in window)) {
a = 'client';
e = Document.documentElement || Document.body;
}
return { width : e[a + 'Width'], height : e[a + 'Height'] };
},
update = function () {
var vw = (getSize().width / 100);
Document.querySelector('html').style.fontSize = vw + 'px';
};
Document.addEventListener("resize", update());
}
function run() {
return new ViewPort();
}
window.viewport = run; …Run Code Online (Sandbox Code Playgroud) javascript ×3
angular ×1
angular-cli ×1
css ×1
defined ×1
ecmascript-6 ×1
express ×1
fluid-layout ×1
font-size ×1
generator ×1
html ×1
https ×1
jshint ×1
node.js ×1
p7b ×1
sass ×1
ssl ×1