我有一个问题,我没有想法,如何解决.在我的react组件中,我显示了一长串数据,底部显示了很少的链接.点击任何链接后,我用新的链接集合填写列表,需要滚动到顶部.
问题是 - 如何在渲染新集合后滚动到顶部?
'use strict';
// url of this component is #/:checklistId/:sectionId
var React = require('react'),
Router = require('react-router'),
sectionStore = require('./../stores/checklist-section-store');
function updateStateFromProps() {
var self = this;
sectionStore.getChecklistSectionContent({
checklistId: this.getParams().checklistId,
sectionId: this.getParams().sectionId
}).then(function (section) {
self.setState({
section,
componentReady: true
});
});
this.setState({componentReady: false});
}
var Checklist = React.createClass({
mixins: [Router.State],
componentWillMount: function () {
updateStateFromProps.call(this);
},
componentWillReceiveProps(){
updateStateFromProps.call(this);
},
render: function () {
if (this.state.componentReady) {
return(
<section className='checklist-section'>
<header className='section-header'>{ this.state.section.name } …Run Code Online (Sandbox Code Playgroud) 我创建了类型为"MSBuild"的构建步骤,将Target设置为"Clean; Build; Publish",将命令行参数添加到/ p:Configuration = Release; PublishDir = M:\ MyPackage
运行配置后,我获得了"成功"状态,但M:\ MyPackage文件夹为空.
我只需要在同一台计算机上的目录中恢复部署包文件,但不要部署到服务器或其他地方
我正在尝试从MacVim切换到VSCode,并且使用VSCode Vim扩展。到目前为止,我发现的最烦人的事情是:如果我使用/命令进行搜索-我无法禁用突出显示搜索结果。
您能否帮助我找到一种方法,在完成搜索后如何隐藏搜索结果突出显示?
我刚开始学习Swift并尝试理解模式匹配.
我找到了下一个例子:
private enum Entities{
case Operand(Double)
case UnaryOperation(Double -> Double)
case BinaryOperation((Double, Double) -> Double)
}
Run Code Online (Sandbox Code Playgroud)
后来我使用模式匹配来确定实体的类型
func evaluate(entity: Entities) -> Double? {
switch entity{
case .Operand(let operand):
return operand;
case .UnaryOperation(let operation):
return operation(prevExtractedOperand1);
case .BynaryOperation(let operation):
return operation(prevExtractedOperand1, prevExtractedOperand2);
}
}
Run Code Online (Sandbox Code Playgroud)
获取相关值的语法似乎有点奇怪,但它工作正常.
之后我发现,在if语句中可以使用模式匹配,所以我试着用同样的方法if
if case entity = .Operand(let operand){
return operand
}
Run Code Online (Sandbox Code Playgroud)
但编译器抛出错误预期','分隔符,我怀疑,这与错误的真正原因没有任何共同之处.
你能不能帮助我理解,我在if声明中尝试使用模式匹配有什么问题?
我想将bootstrap.js和jquery.js(都是用npm安装)组合到vendors.js文件中,但仍然可以通过调用来使用jquery require('$').所以我创建了gulp任务:
'use strict';
var gulp = require('gulp'),
helpers = require('./../utilities/gulp-helpers'),
source = require('vinyl-source-stream'),
plumber = require('gulp-plumber'),
browserifyShim = require('browserify-shim'),
browserify = require('browserify');
gulp.task('bulld-frontend:vendors', function(done) {
var build = browserify({
entries: [
'jquery',
'bootstrap'
]
});
build
.transform(browserifyShim)
.require('jquery')
.bundle()
.pipe(source('vendors.js'))
.pipe(gulp.dest('build/public/js'))
.pipe(plumber({
errorHandler: helpers.logError
}));
done();
});
Run Code Online (Sandbox Code Playgroud)
然后将配置添加到package.json
"browser": {
"bootstrap": "./node_modules/bootstrap/dist/js/bootstrap.js",
"jquery": "./node_modules/jquery/dist/jquery.js"
},
"browserify-shim": "./gulp/utilities/shim-config.js",
},
Run Code Online (Sandbox Code Playgroud)
最后在gulp/utilities/shim-config.js中配置我的垫片
'use strict';
module.exports = {
'jquery' : '$',
'bootstrap' : { 'depends': { 'jquery': 'jQuery'} } …Run Code Online (Sandbox Code Playgroud) 今天我发现了一段笨拙的代码:
if segue.identifier == "settings" {
if let settingsController = segue.destination as? SettingsController
{
//...setup settings controller here
}
} else if segue.identifier == "mocks" {
if let mocksController = segue.destination as? MocksController
{
//...setup mocks controller here controller here
}
}
//... and a lot of if-elses
Run Code Online (Sandbox Code Playgroud)
我真的很讨厌if-else-if在我的代码中决定重构这篇文章switch.不幸的是,我对快速模式匹配的了解非常有限,所以我能做的最好的事情是:
switch segue.identifier! {
case "mocks" where segue.destination is MocksController:
let mocksController = segue.destination as! MocksController
// do corresponding staff here
break
case "settings" where segue.destination is SettingsController: …Run Code Online (Sandbox Code Playgroud) swift ×2
asp.net-mvc ×1
browserify ×1
deployment ×1
enums ×1
jquery ×1
matching ×1
msbuild ×1
reactjs ×1
render ×1
scroll ×1
teamcity ×1