我正在关注Chang Wang的教程,使用HOC和ReactTransitionGroup(第1 部分第2部分)与Huan Ji的页面转换教程(Link)一起制作可重复使用的React过渡.
我面临的问题是,React.cloneElement似乎没有将更新的道具传递给其中一个孩子,而其他孩子正确地接收更新的道具.
TransitionContainer.js
TransitionContainer是一个容器组件,类似于AppHuan Ji的教程.它为它的孩子注入一片状态.
这些孩子TransitionGroup都是HOC的一个实例Transition(代码进一步向下)
import React from 'react';
import TransitionGroup from 'react-addons-transition-group';
import {connect} from 'react-redux';
class TransitionContainer extends React.Component{
render(){
console.log(this.props.transitionState);
console.log("transitionContainer");
return(
<div>
<TransitionGroup>
{
React.Children.map(this.props.children,
(child) => React.cloneElement(child, //These children are all instances of the Transition HOC
{ key: child.props.route.path + "//" + child.type.displayName,
dispatch: this.props.dispatch,
transitionState: this.props.transitionState
}
)
)
}
</TransitionGroup>
</div>
)
} …Run Code Online (Sandbox Code Playgroud) animation reactjs react-router reactcsstransitiongroup redux
我正在尝试使用 Python 的 Popen 来更改我的工作目录并执行命令。
pg = subprocess.Popen("cd c:/mydirectory ; ./runExecutable.exe --help", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
buff,buffErr = pg.communicate()
Run Code Online (Sandbox Code Playgroud)
但是,powershell 返回“系统找不到指定的路径”。路径确实存在。
如果我跑
pg = subprocess.Popen("cd c:/mydirectory ;", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
Run Code Online (Sandbox Code Playgroud)
它返回同样的东西。
但是,如果我运行这个:(没有分号)
pg = subprocess.Popen("cd c:/mydirectory",stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
Run Code Online (Sandbox Code Playgroud)
命令返回没有错误。这让我相信分号是问题。这种行为的原因是什么,我该如何解决?
我知道我只能做 c:/mydirectory/runExecutable.exe --help,但我想知道为什么会这样。
更新 :
我已经测试过将路径传递给 powershell 作为 Popenexecutable参数的参数。只是powershell.exe可能还不够。要找到 的真正绝对路径powershell,请执行where.exe powershell。然后你可以将它传递给 Popen。请注意,这shell仍然是正确的。它将使用默认 shell,但将命令传递给powershell.exe
powershell = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
pg = subprocess.Popen("cd c:/mydirectory ; ./runExecutable.exe", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, executable=powershell)
buff,buffErr = pg.communicate() …Run Code Online (Sandbox Code Playgroud) animation ×1
popen ×1
powershell ×1
python ×1
react-router ×1
reactjs ×1
redux ×1
subprocess ×1