我试图实现经过身份验证的路由,但发现React Router 4现在阻止了它的工作:
<Route exact path="/" component={Index} />
<Route path="/auth" component={UnauthenticatedWrapper}>
<Route path="/auth/login" component={LoginBotBot} />
</Route>
<Route path="/domains" component={AuthenticatedWrapper}>
<Route exact path="/domains" component={DomainsIndex} />
</Route>
Run Code Online (Sandbox Code Playgroud)
错误是:
警告:您不应该使用
<Route component>和使用<Route children>相同的路线;<Route children>将被忽略
在这种情况下,有什么正确的方法来实现这个?
它出现在react-router(v4)docs中,它表明了类似的东西
<Router>
<div>
<AuthButton/>
<ul>
<li><Link to="/public">Public Page</Link></li>
<li><Link to="/protected">Protected Page</Link></li>
</ul>
<Route path="/public" component={Public}/>
<Route path="/login" component={Login}/>
<PrivateRoute path="/protected" component={Protected}/>
</div>
</Router>
Run Code Online (Sandbox Code Playgroud)
但是,将一堆路线组合在一起是否有可能实现这一目标?
UPDATE
好的,经过一些研究,我想出了这个:
import React, {PropTypes} from "react"
import {Route} from "react-router-dom"
export default class AuthenticatedRoute extends React.Component …Run Code Online (Sandbox Code Playgroud) 我知道如果您事先知道该单位,您可以从SASS中的数字中删除单位:
$number: 16px;
$without-unit: 16px / 1px;
@warn $without-unit; // 16
Run Code Online (Sandbox Code Playgroud)
但是有可能在不知道单位是什么的情况下从一个数字中剥离单位吗?
@function strip-unit($number) {
// magic code here...
}
@warn strip-unit(16px); // 16
Run Code Online (Sandbox Code Playgroud) 我正在研究从数据库中获取数据并构造protobuff消息的东西.鉴于可以从数据库中为某些字段提取空值,我将在尝试构造protobuff消息时获得Null指针异常.从线程http://code.google.com/p/protobuf/issues/detail?id=57中的protobuffs中不支持知道null ,我想知道处理NPE的唯一其他方法是抛出是将手动检查插入到与原型相对应的java文件中,如下所示!
message ProtoPerson{
optional string firstName = 1;
optional string lastName = 2;
optional string address1 = 3;
}
ProtoPerson.Builder builder = ProtoPerson.Builder.newBuilder();
if (p.getFirstName() != null) builder.setFirstName(p.getFirstName());
if (p.getLastName() != null) builder.setLastName(p.getLastName());
if (p.getAddress1() != null) builder.setAddress1(p.getAddress1());
...
Run Code Online (Sandbox Code Playgroud)
那么有人可以澄清在protobuff构造期间是否还有其他可行的有效方法来处理空值?
我知道你可以在Chrome Inspector中看到事件监听器,但是我正在做一些调试工作,并且有很多事件监听器在我周围我想要禁用一些而不编辑代码

有没有办法从Webkit检查器快速禁用事件侦听器?
也许看一下并removeEventListener在监听器的控制台中输入一些代码?我该怎么做?例如,我如何删除上面的"点击"听众
是否有可能在protobuf-net中生成可空的成员?
message ProtoBuf1 {
optional Int32? databit = 1;
optional Nullable<bool> databool = 2;
}
Run Code Online (Sandbox Code Playgroud) 在Visual Studio 2010 SP1中,我打开了一个XML Schema(XSD)文件,其中包含以下行:
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
Run Code Online (Sandbox Code Playgroud)
xs:import 它下面有一条蓝色波浪线,当你将鼠标悬停在它上面时,你会得到以下工具提示:
请求类型'System.Net.WebPermission,System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败.
如何授予此权限以便下载架构?谢谢.
更新: 我忘记在原帖中提到这一点,但我已经回顾了Craig Watson的解决方法.它违背了让Visual Studio"自动下载DTD和模式"的目的(工具>选项>文本编辑器> XML>杂项).我希望找到解决方案而不是解决方法.谢谢.
Microsoft最近发布了Web Tools 2012.2.发行说明声明它支持
较少的编辑和编译器支持,可以使用LESS构建动态CSS.
但是当我保存LESS文件时,它不会像Web Essentials那样输出相应的CSS文件.我怎么做到这一点?
我有一个启动工作的powershell脚本
start-job -scriptblock {
while($true) {
echo "Running"
Start-Sleep 2
}
}
Run Code Online (Sandbox Code Playgroud)
然后它继续执行脚本的其余部分.
那项工作对于该过程的PID来说是一种监控.
我想每隔n秒同步打印PID,而不必结束工作.
例如,当正在执行脚本的其余部分时,我希望在我的控制台中看到输出.
在PowerShell中有类似的东西吗?
谢谢.
我想在 Notepad++ 中编辑 Gemfile,但由于 Gemfile 没有扩展名,因此似乎没有办法让 Notepad++ 自动将 Gemfile 检测为 Ruby 文件。每次打开 Gemfile 时我都必须手动设置语言。
有没有办法让 Notepad++ 根据文件的全名而不仅仅是扩展名来识别文件的语言?有这个插件吗?谢谢。
我正在查看John Gruber在Perl中编写的MarkDown代码,并且有一个子命令_Detab将标签转换为空格,同时保留文本的缩进.有问题的代码行是Markdown.pl中的1314:
$text =~ s{(.*?)\t}{$1.(' ' x ($g_tab_width - length($1) % $g_tab_width))}ge;
Run Code Online (Sandbox Code Playgroud)
这不会导致不必要的回溯吗?以下模式不会更有效地执行吗?
/([^\t\n]*)\t/
Run Code Online (Sandbox Code Playgroud)
或者我错过了什么?谢谢.
顺便说一句,我只是否定\n而不是\r因为所有的换行都是\n事先标准化的.
javascript ×2
c# ×1
function ×1
inspector ×1
java ×1
less ×1
markdown ×1
notepad++ ×1
null ×1
performance ×1
perl ×1
powershell ×1
protobuf-net ×1
react-router ×1
reactjs ×1
regex ×1
sass ×1
scripting ×1
start-job ×1
webkit ×1
xml ×1
xsd ×1