我已经定义了一些任务gulpfile.js,我想使用gulp-watch插件(在新文件上运行任务).我的问题是,因为我找不到任何东西,我可以在运行watch(来自插件)功能时运行我现有的任务吗?
var gulp = require('gulp'),
watch = require('gulp-watch'),
...;
gulp.task('lint', function () {
return gulp.src(path.scripts)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('watch', function () {
watch({ glob: 'app/**/*.js' }); // Run 'lint' task for those files
});
Run Code Online (Sandbox Code Playgroud)
因为我不想watch()在我的每项任务中都包含任务.我想只有一项任务 - 手表,它将结合所有"手表".
-----编辑----(因为我可能不太明白我的观点):
我需要从任务内部运行gulp('watch')任务.例如:
就像我做的那样gulp.watch:
gulp.task('watch', function () {
gulp.watch('files', ['task1', 'task2']);
});
Run Code Online (Sandbox Code Playgroud)
我需要做同样的事情,但有gulp-watch插件,类似的东西(我知道它不会起作用):
var watch = require('gulp-watch');
gulp.task('watch', function () {
watch({ glob: 'files' }, ['task1', 'task2']);
});
Run Code Online (Sandbox Code Playgroud) 我想测试AJAX方法(vanilla XHR),我找不到使用Jest框架的方法.我找到mock-ajax.js了Jasmine,问题是我找不到安装它的方法.
是否有更好的方法在Jest中单元测试Ajax函数?
我在JavaScript中有一个特定的页面打印问题.我需要在另一个选项卡上打开我的页面,删除所有脚本(这样:$(document).get(0).documentElement.innerHTML.replace(/<script[^>]+>.*?<\/script>/gi, '')然后window.print()在新选项卡中调用,然后关闭它.
那是因为脚本中的错误导致打印问题.负责整个打印的代码:
var w = window.open();
w.document.write(
$(document).get(0).documentElement.innerHTML.replace(/<script[^>]+>.*?<\/script>/gi,'')
);
w.document.close();
var loadingImagesInterval = setInterval(function() {
var imgs = w.document.querySelectorAll('img');
for (var i = 0; i < imgs.length; i++) {
if (!imgs[i].complete) return;
}
clearInterval(loadingImagesInterval);
w.focus();
w.print();
w.close();
}, 100);
Run Code Online (Sandbox Code Playgroud)
基本上,问题是,在iOS上,w.print()似乎不会阻止代码执行,直到打印视图中的确认/取消,并w.close()立即调用.所有其他浏览器都可以正常工作:Mac Chrome,Mac Safari,IE11,Mac Firefox.一切都很好.不是iOS Safari.
我试过这段代码,但是效果不好:
w.matchMedia('print').addListener(function(mql) {
if (!mql.matches) {
w.close();
}
})
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来处理我的问题?
我需要在.jar我的自定义cordova插件中包含3rd party 插件。我找不到任何方法可以做到这一点。
fe我的一些实际代码如下所示(在中plugin.xml):
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="AztecReader">
<param name="android-package" value="com.example.aztecreadermobilas.AztecReaderPlugin"/>
</feature>
</config-file>
<source-file src="src/android/AztecReaderPlugin.java" target-dir="src/com/example/aztecreadermobilas" />
</platform>
Run Code Online (Sandbox Code Playgroud)
我需要包括的库:
/libs
/armeabi
/libAztecLibrary.so
/armeabi_v2
/libAzteclibraryv2.so
/AztecReader.jar
Run Code Online (Sandbox Code Playgroud) 是否可以在不手动模拟的情况下测试QPromise 库Jest?
我正在构建“Tanks”游戏,其中我使用 Key 事件在地图上运行我的坦克。实际上我当时只能使用一个键,但我需要有同时上下左右的能力。
这是我的单键事件代码:
switch(event->key())
{
case Qt::Key_Up:
if(!ui->widget->playerList[playerID]->canMove(0.3, 20, 20, -20, -20, 1.5)) return;
ui->widget->playerList[playerID]->move(0.3);
ui->widget->updateGL();
break;
case Qt::Key_Down:
if(!ui->widget->playerList[playerID]->canMove(-0.2, 20, 20, -20, -20, 1.5)) return;
ui->widget->playerList[playerID]->move(-0.2);
ui->widget->updateGL();
break;
case Qt::Key_Right:
ui->widget->playerList[playerID]->rotate(10);
ui->widget->updateGL();
break;
case Qt::Key_Left:
ui->widget->playerList[playerID]->rotate(-10);
ui->widget->updateGL();
break;
case Qt::Key_Q:
ui->widget->playerList[playerID]->rotateCannon(10);
ui->widget->updateGL();
break;
case Qt::Key_E:
ui->widget->playerList[playerID]->rotateCannon(-10);
ui->widget->updateGL();
break;
default:
QMainWindow::keyPressEvent(event);
break;
}
Run Code Online (Sandbox Code Playgroud) 我有一个包含一些数据的表,表中的每个元素都是一个React类组件.它看起来像这样:

我想要的是有一个"全部检查"功能的复选框(左上角的复选框).事情是我不知道如何解决这个因为props和state.
我在单个元素组件中有这样的代码:
getInitialState: function() {
return { component: this.props.data };
},
render: function() {
var data = this.state.component;
data = data.set('checked', this.props.data.get('checked'));
...
}
Run Code Online (Sandbox Code Playgroud)
我知道我不应该得到checked参数,props但这只是暂时的.
我遇到的问题是:当我checked在父级更新param时它不会更新状态,因为getInitialState刷新后没有调用(是的,我知道应该是这样).
我的问题是:我可以以某种方式更新子组件的状态吗?或者是实现这一目标的更好方法.
javascript ×5
jestjs ×2
c++ ×1
cordova ×1
gulp ×1
gulp-watch ×1
java ×1
qt ×1
reactjs ×1
refluxjs ×1
unit-testing ×1