我刚刚react-router
从v3 更换为v4.
但我不知道如何以编程方式导航到一个成员函数Component
.即在handleClick()
功能中我想/path/some/where
在处理一些数据后导航到.我曾经这样做过:
import { browserHistory } from 'react-router'
browserHistory.push('/path/some/where')
Run Code Online (Sandbox Code Playgroud)
但我在v4中找不到这样的接口.
如何使用v4导航?
我尝试使用以下代码将Decimal转换为Int:
Int(pow(Decimal(size), 2) - 1)
Run Code Online (Sandbox Code Playgroud)
但我得到:
.swift:254:43: Cannot invoke initializer for type 'Int' with an argument list of type '(Decimal)'
Run Code Online (Sandbox Code Playgroud)
在这里我知道pow正在返回a Decimal
但似乎Int没有构造函数和成员函数可以转换Decimal
为Int
.
如何在Swift 3中将Decimal转换为Int?
我如何在Mongoose中使用聚合和find
一起?
即我有以下架构:
const schema = new Mongoose.Schema({
created: { type: Date, default: Date.now() },
name: { type: String, default: 'development' }
followers: [{ type: Mongoose.Schema.ObjectId, ref: 'Users'}]
...
})
export default Mongoose.model('Locations', schema)
Run Code Online (Sandbox Code Playgroud)
如何仅使用字段name
和查询用户followers_count
.
followers_count
:长度followers
.
在那里,我知道我们可以使用select来获得该字段name
.
我们怎么能算得上followers
?
mongoose mongodb node.js mongodb-query aggregation-framework
我试着为React.js应用程序编写测试.一切都很顺利但是在用Git跟踪目录之后(用它做了一个Git回购).测试失败,出现以下错误
2017-01-15 05:05 node[1278] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-15 05:05 node[1278] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:160
throw er; // Unhandled 'error' event
^
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1022:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)
Run Code Online (Sandbox Code Playgroud)
我确信这是因为.git
目录,因为当我删除.git
目录时它正在运行而没有错误.似乎在观看文件时发生异常.我的开发环境是MacOS 10.12.2和节点6.9.4.我该如何解决这个问题?
我使用的CC-测试记者上传的测试覆盖率结果Code Climate
从CircleCI
但是运行相同的构建失败并显示以下消息:
Error: response from https://api.codeclimate.com/v1/test_reports.
HTTP 409: A test report for commit
858d3fa0c92ec5a546bde3991f57523768dac0c2 already exists
Run Code Online (Sandbox Code Playgroud)
如何让它通过CI脚本或覆盖它而不会失败?
我在 CircleCI 中Press [ENTER] to continue or ctrl-c to cancel adding it
使用apt-get
时得到了。我怎样才能自动绕过它?
我尝试使用-y
但没有效果!
我试图ignore_malformed
在 ElasticSearch Mapping 中输入一个字段的属性。
EClient.indices.putMapping(
{
index: 'activities',
type: 'user',
body: {
properties: {
meta: {
type: 'object',
ignore_malformed: true, // meta is dynamic
},
},
},
},
(err, res) => {
console.info('Put Mapping Error:', err);
console.info('Put Mapping Res:', res);
}
);
Run Code Online (Sandbox Code Playgroud)
但我得到
response: '{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [meta] has unsupported parameters: [ignore_malformed : true]"}],"type":"mapper_parsing_exception","reason":"Mapping definition for [meta] has unsupported parameters: [ignore_malformed : true]"},"status":400}'
Run Code Online (Sandbox Code Playgroud)
根据文档:ignore_malformed它应该可以工作。有人可以告诉我我的代码有什么问题吗?
我有以下gulp任务:
// Compile ES6 to ES5 and copy to dist
gulp.task('babel', () =>
gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' })
.pipe(plugins.newer('dist'))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.sourcemaps.write('.', {
includeContent: false,
sourceRoot(file) {
return path.relative(file.path, __dirname);
}
}))
.pipe(gulp.dest('dist'))
);
Run Code Online (Sandbox Code Playgroud)
根据Gulp Doc(gulp.src),我了解到gulp.src会发出匹配提供的glob或glob数组的文件.
但我无法理解'... paths.js'的含义.项目目录中没有以"paths.js"命名的文件.
有没有人可以帮助我理解它?
我已经把多UITextFields
到UIViewController
故事板。
我正在使用IQKeyboardManagerUITextFields
在它们聚焦时在键盘上滚动。
当我单击键盘工具栏中的下一个按钮时,另一个UITextField
正在获得焦点,而当前一个失去焦点。
我怎样才能控制焦点的顺序的的UITextField
S按键盘工具栏按钮?
我通常会在HTML文档的主体中添加一个类,如下所示:
document.body.classList.toggle('darkClass', this.props.isDark)
Run Code Online (Sandbox Code Playgroud)
但我不知道如何获得整个html
元素.如何在Javascript中引用它?
var html = ?
html.classList.toggle(...)
Run Code Online (Sandbox Code Playgroud) node.js ×4
ecmascript-6 ×3
circleci ×2
ios ×2
javascript ×2
reactjs ×2
swift ×2
code-climate ×1
dom ×1
gulp ×1
html ×1
jestjs ×1
linux ×1
mongodb ×1
mongoose ×1
shell ×1
swift3 ×1
ubuntu-16.04 ×1
uistoryboard ×1