这是导致我麻烦的文件:
var Routers = React.createClass({
getInitialState: function(){
return{
userName: "",
relatives: []
}
},
userLoggedIn: function(userName, relatives){
this.setState({
userName: userName,
relatives: relatives,
})
},
render: function() {
return (
<Router history={browserHistory}>
<Route path="/" userLoggedIn={this.userLoggedIn} component={LogIn}/>
<Route path="feed" relatives={this.state.relatives} userName={this.state.userName} component={Feed}/>
</Router>
);
}
});
Run Code Online (Sandbox Code Playgroud)
我试图将新的this.state.relatives和this.state.userName通过路线传递到我的"feed"组件.但我收到此错误消息:
警告:[react-router]你无法改变; 它会被忽略
我知道为什么会发生这种情况,但不知道我应该如何将状态传递给我的"feed"组件.在过去的5个小时里我一直在努力解决这个问题,而且我已经非常绝望了!
请帮忙!谢谢
下面的答案很有帮助,我感谢他们,但他们并不是最简单的方法.在我的情况下做到这一点的最好方法是:当您更改路线时,您只需将消息附加到它,如下所示:
browserHistory.push({pathname: '/pathname', state: {message: "hello, im a passed message!"}});
Run Code Online (Sandbox Code Playgroud)
或者如果你通过链接这样做:
<Link
to={{
pathname: '/pathname',
state: { message: 'hello, im a passed message!' }
}}/>
Run Code Online (Sandbox Code Playgroud)
来源: …
我正在尝试使用skrollr创建一个简单的视差动画:我的网站在Chrome/Mac上运行良好,但我在ipad上看到异常行为.
在ipad上(在IOS模拟器上测试),
data-start/中定义的边界内向相反方向滚动(向下)data-top-bottom在桌面上,效果我可以,如果我劈模拟的效果div#hero要position: fixed;在Chrome浏览器开发工具.
<div id="skrollr-body"></div>刚刚结束</body>标签有什么建议?
我正在创建的布局在Safari中不起作用,尽管它在Chrome中运行良好.我有一种感觉它与.wrapper或有关,.frame但我尝试设置Flex Shrink值0无济于事.
.frame {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
height: 100vh;
position: relative;
overflow: hidden;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
}
.wrapper {
-webkit-flex: 1 0 auto !important;
-ms-flex: 1 0 auto …Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的基于flexbox的页面,可以在Google Chrome(版本44.0.2403.157)中正确呈现,但在Safari(版本8.0.2(10600.2.5))中则不能.我已经添加了所有相关的前缀(我认为)并且花了很多时间查看检查器,但我似乎没有找到问题的原因.
该页面由一个容器和两个弹性行组成.第一个弹性行(标题)应该具有高度拉伸以适合其内容.第二个flex行(内容)应该具有浏览器高度减去标题高度的高度,此容器的溢出设置为滚动.当内容容器不必滚动时,代码工作正常,但只要内容容器有任何溢出,标题行就不再包含其内容.可能是什么导致了这个?
代码:
<html>
<head>
<style>
.box {
display: -ms-flexbox; /* IE 10 */
display: -webkit-flex; /* Safari 6 */
display: flex; /* Modern browsers */
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
flex-flow: column;
height: 100%;
width: 100%;
border: 2px solid;
}
.box .row {
flex: 0 1 30px;
border: 2px solid;
width: 100%;
}
.box .row.header {
-ms-flex: 0 1 auto;
-webkit-flex: 0 1 auto;
flex: 0 1 auto;
}
.box .row.content {
-ms-flex: 1 1 auto;
-webkit-flex: …Run Code Online (Sandbox Code Playgroud) 我正在使用聚合来计算一列布尔值.我想要真值的数量.
DJANGO代码:
count = Model.objects.filter(id=pk).aggregate(bool_col=Count('my_bool_col')
Run Code Online (Sandbox Code Playgroud)
这将返回所有行的计数.
SQL QUERY应该是:
SELECT count(CASE WHEN my_bool_col THEN 1 ELSE null END) FROM <table_name>
Run Code Online (Sandbox Code Playgroud)
这是我的实际代码:
stats = Team.objects.filter(id=team.id).aggregate(
goals=Sum('statistics__goals'),
assists=Sum('statistics__assists'),
min_penalty=Sum('statistics__minutes_of_penalty'),
balance=Sum('statistics__balance'),
gwg=Count('statistics__gwg'),
gk_goals_avg=Sum('statistics__gk_goals_avg'),
gk_shutout=Count('statistics__gk_shutout'),
points=Sum('statistics__points'),
)
Run Code Online (Sandbox Code Playgroud)
感谢Peter DeGlopper建议使用django-aggregate-if
这是解决方案:
from django.db.models import Sum
from django.db.models import Q
from aggregate_if import Count
stats = Team.objects.filter(id=team.id).aggregate(
goals=Sum('statistics__goals'),
assists=Sum('statistics__assists'),
balance=Sum('statistics__balance'),
min_penalty=Sum('statistics__minutes_of_penalty'),
gwg=Count('statistics__gwg', only=Q(statistics__gwg=True)),
gk_goals_avg=Sum('statistics__gk_goals_avg'),
gk_shutout=Count('statistics__gk_shutout', only=Q(statistics__gk_shutout=True)),
points=Sum('statistics__points'),
)
Run Code Online (Sandbox Code Playgroud) 我已经整理了网格的工作示例,并希望将IconMenu添加到网格的每一行的列中.我看到了图标按钮,但是当我点击它时,我没有看到菜单.下面是网格的代码.
有没有人设法使用来自material-ui的IconMenu 固定数据表?
require('fixed-data-table/dist/fixed-data-table.css');
var React = require('react');
var PropTypes = React.PropTypes;
var FixedDataTable = require('fixed-data-table');
var Table = FixedDataTable.Table;
var Column = FixedDataTable.Column;
// Material-UI
let MenuItem = require('material-ui/lib/menus/menu-item');
let IconMenu = require('material-ui/lib/menus/icon-menu');
let IconButton = require('material-ui/lib/icon-button');
let Colors = require('material-ui/lib/styles/colors');
let MoreVertIcon = require('material-ui/lib/svg-icons/navigation/more-vert');
function cellMenuRenderer(cellData, key, rowData, rowIndex, columnData, width) {
let button = (
<IconButton
touch={true}
tooltip='Click to see menu.'
tooltipPosition='bottom-left'>
<MoreVertIcon color={Colors.grey400} />
</IconButton>
);
return (
<IconMenu iconButtonElement={button}>
<MenuItem primaryText="Edit" …Run Code Online (Sandbox Code Playgroud) 编辑: 这是我的问题的主要编辑,基于评论中的反馈,以及对meta.stackoverflow的一些阅读.
我改变了目标,现在我的首要任务是在Laravel和WP之间路由顶级URL:我不再寻求共享代码/数据库/用户信誉等.
问题:我需要哪些重写规则来实现这样的URL结构:
/ // (home) delivered by WP
/content1 // WP
/content(n) // WP
/dashboard // delivered by Laravel
/widgets/mywidget/ // Laravel
Run Code Online (Sandbox Code Playgroud)
我按如下方式设置了我的文件,并测试了每个应用程序彼此独立工作.(即如果Laravel的重写规则是唯一使用的,Laravel使用laravel-index.php工作正常)
来自网络根目录:public_html /
/wordpress
/laravel3 // app dir
/css // these are from the laravel public dir
/images //
/js, etc //
/index.php // WP index.php
/laravel-index.php // laravel's index.php
Run Code Online (Sandbox Code Playgroud)
我在共享托管环境中,无法访问httpd.conf.
这是我的.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase …Run Code Online (Sandbox Code Playgroud) Redux表单验证示例仅包括单个字段验证.
拥有一定数量的相同字段的列表,我如何建模验证,要求至少有一个输入是有效的电子邮件地址?
例如,对于由以下字段组成的给定表单:
如何编写需要特殊用户4始终设置的验证功能,以及前3个用户中的任何一个?
我使用XAMPP开发wordpress主题,我想使用ManageWP来管理/克隆网站到生产服务器.我已经按照我可以找到的关于此事的每个教程,但无法设法获得对我的localhost的外部访问!
这个相关的SE答案看起来很简单!
我很确定我已经完成了最后三步,(没有防火墙,端口80 TCP和UDP> 80,服务器IP由MAC地址分配)但我不知道如何做第一步(我试过玩在httpd.conf中通过将ServerName设置为我的外部IP地址,但这只是一个狂野的随机失败:)
虽然端口转发处于活动状态,但我可以看到网站:##.###.64.188/mysite.dev(我的外部IP),而我在本地网络上,但如果我通过我的3g移动连接连接,我会得到:
Not Found
The requested URL http://<snip> was not found on this server
Apache Server at ##.###.64.188 Port 3128
Run Code Online (Sandbox Code Playgroud)
这似乎表明我在附近的某个地方!但不知道从哪里开始......
有什么建议?蒂姆,蒂姆
运行:
我想在我的网页上使用SVG.
但它的颜色是黑色的.所以,我希望它能被改变.所以,我做了 -
.red_color_svg
{
color: red;
border: 5px solid currentColor;
fill: currentColor;
}Run Code Online (Sandbox Code Playgroud)
<object type="image/svg+xml" data="https://rawcdn.githack.com/encharm/Font-Awesome-SVG-PNG/master/black/svg/heart.svg" class="weather_icon red_color_svg circle"></object>Run Code Online (Sandbox Code Playgroud)
导入heart_border.svg文件并使其颜色为红色.但它不会像你看到输出那样起作用.
任何人都可以帮我解决这个问题吗?
非常感谢您提前帮助.
css ×3
reactjs ×3
css3 ×2
flexbox ×2
html ×2
safari ×2
.htaccess ×1
aggregate ×1
apache ×1
django ×1
html5 ×1
iconmenu ×1
ipad ×1
javascript ×1
localhost ×1
material-ui ×1
parallax ×1
python ×1
react-router ×1
redux ×1
redux-form ×1
skrollr ×1
svg ×1
validation ×1
xampp ×1