为react-select组件(https://github.com/JedWatson/react-select)选项设置样式的最佳方法是什么?
我可以很好地定位选择本身,例如:
...
import Select from 'react-select'
...
const styles = {
fontSize: 14,
color: 'blue',
}
<Select
options={[1,2,3,4]}
placeholder={'Select something'}
clearable={false}
style={styles.select}
/>
Run Code Online (Sandbox Code Playgroud)
问题是,展开选择时的实际选项仍然是默认样式.如何定位这些样式选项?
我正在将 Webpack 实施到旧版 Express 前端应用程序中。我已经按照说明实现了 webpack-dev-middleware 和 webpack-hot-middleware,但我不知道如何实际引用 webpack-dev-middleware 在我的索引文件中构建的内存包。
server.js:
......
// Webpack HMR
if (isDevelopment) {
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
const compiler = webpack(webpackConfig);
app.use(
require('webpack-dev-middleware')(compiler, {
noInfo: false,
hot: true,
publicPath: webpackConfig.output.publicPath,
})
);
app.use(require('webpack-hot-middleware')(compiler));
}
....
Run Code Online (Sandbox Code Playgroud)
webpack.config.js:
...
entry: {
app: [
'webpack-hot-middleware/client?path=http://localhost:3001/__webpack_hmr&timeout=2000&overlay=false',
path.join(__dirname, './public/js/boot/app.js'),
],
deps: [
'webpack-hot-middleware/client?path=http://localhost:3001/__webpack_hmr&timeout=2000&overlay=false',
path.join(__dirname, './public/js/boot/deps.js'),
]
},
output: {
path: isDevelopment ? path.join(__dirname, './public/js/bundles') : path.join(__dirname, './dist/js/bundles'),
publicPath: '/',
filename: '[name].js'
},
....
Run Code Online (Sandbox Code Playgroud)
Base view: server/views/index.jade: …
我在这里问这个问题感到很疯狂,但是我找不到任何有关如何提交表单和捕获RN数据的好的教程。我发现的所有东西都是有人在推动一个库“只是npm install react-native-form-genie-magic-box并在您的项目中调用它 ”。
但是我只想知道-如何在香草React Native中提交表单。
示例代码:
AuthContainer
class AuthContainer extends Component {
render() {
const { errorMessage, handleLogin } = this.props
return (
<Login
errorMessage={errorMessage}
onLoginClick={(e) => handleLogin(e)}
/>
)
}
}
.....
const mapDispatchToProps = (dispatch) => {
return {
handleLogin: (e) => {
e.preventDefault()
const form = e.target
const data = serialize(form, {hash: true})
const creds = { email:data.email, password: data.password }
dispatch(loginUser(creds))
},
}
}
Run Code Online (Sandbox Code Playgroud)
登录
import { Container, Content, Form, …Run Code Online (Sandbox Code Playgroud) 我正在寻找帮助调试Rails has_many的问题:通过关联.我有3个模型,Package,Venue和我的连接表,Packagevenue
package.rb
class Package < ActiveRecord::Base
has_many :packagevenues
has_many :venues, through: :packagevenues
end
Run Code Online (Sandbox Code Playgroud)
venue.rb
class Venue < ActiveRecord::Base
has_many :packagevenues
has_many :packages, through: :packagevenues
end
Run Code Online (Sandbox Code Playgroud)
packagevenue.rb
class Packagevenue < ActiveRecord::Base
belongs_to :venues
belongs_to :packages
end
Run Code Online (Sandbox Code Playgroud)
packagevenues表的模式
create_table "packagevenues", force: :cascade do |t|
t.integer "package_id"
t.integer "venue_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Run Code Online (Sandbox Code Playgroud)
测试用例:
Packagevenue.first
Packagevenue Load (0.3ms) SELECT "packagevenues".* FROM "packagevenues" ORDER BY "packagevenues"."id" ASC LIMIT 1
=> #<Packagevenue:0x007fac12209750> {
:id …Run Code Online (Sandbox Code Playgroud) 我到处寻找解决方案,但是这个问题的所有常见解决方案都不适用于我.任何帮助是极大的赞赏.
我的问题只是在我做出改变之后,rails best_in_place gem没有保存我的任何数据.它允许我输入新的更改,但是在我按下回车后它不会更新数据库(如果我刷新页面也不起作用,这是RailsCast上这个gem的初始问题).
控制器代码:
def update
respond_to do |format|
if @renter.update_attributes(renter_params)
format.json { render json: @renter }
flash[:success] = "Profile updated"
redirect_to @renter
else
render 'edit'
end
end
Run Code Online (Sandbox Code Playgroud)
结束
查看页面代码
<li><span class="content"><b>Name: </b><%= best_in_place @renter, :name %></span></li>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
编辑:从控制器添加renter_params
def renter_params
params.require(:renter).permit(:name, :email, :password, :password_confirmation)
end
Run Code Online (Sandbox Code Playgroud)
(注意:我的renter_params本身从来没有遇到任何问题,我的更新总是在数据库中保存好)
编辑:从javascripts/application.js添加代码
//= require jquery
//= require best_in_place
//= require best_in_place.purr
//= require jquery_ujs
//= require jquery.purr
//= require bootstrap
//= require turbolinks
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
renters.js.coffee
# Place all the behaviors and …Run Code Online (Sandbox Code Playgroud) 我怎样才能提高为最大允许值QUERY_STRING利用要么thin,puma或unicorn在Rails的Web服务器?我试图向我的 Rails API 发出超过限制的 POST 请求,只需要增加服务器的最大阈值
POST 上的特定错误: Invalid request: HTTP element QUERY_STRING is longer than the (1024 * 10) allowed length.
我只在另一个地方遇到过这个问题(HTTP 查询字符串长度与瘦 web 服务器),我不太明白答案(特别是,在哪里可以找到要在该答案中编辑的 C 文件?)
因此,在我长达几个月的学习JavaScript的过程中,我终于坐下来建造了扫雷.作为奖励,它确实有效!(呃,第一次).
问题是,如果我清除我的电路板然后再动态生成新的游戏板,我的jQuery点击监听器都不会再工作了.游戏适用于第一个文档加载,但点击后不会注册.
完整的jfiddle: http ://jsfiddle.net/3w5zm64y/
与此问题相关的部分:
的index.html
<table class="gameBoard"></table> //the game board is dynamically generated inside of this table
Run Code Online (Sandbox Code Playgroud)
JS代码
$(document).ready(function(){
....
//right click check
$(".left").find('td').on('mousedown',function(e){
if( e.button == 2 ) {
alert('this works only on the first page load');
}
}
$('.gameBoard').text(''); //this is where I clear out everything within the gameBoard table
draw_board(numRows,numCols); //this method puts everything back into the gameBoard table
Run Code Online (Sandbox Code Playgroud)
问题:
$(document).ready(function(){
....
//right click check
$(".left").find('td').on('mousedown',function(e){
if( e.button == 2 ) {
alert('**now this …Run Code Online (Sandbox Code Playgroud) javascript ×2
reactjs ×2
activerecord ×1
css ×1
jquery ×1
native-base ×1
puma ×1
react-native ×1
react-select ×1
ruby ×1
thin ×1
unicorn ×1
webpack ×1