我是使用Laravel和Homestead的新手,并且非常感谢任何帮助或正确的方向.当我运行"php artisan serve"时,我已经成功地进入了"你已经到达"屏幕但是当我尝试通过Vagrant做同样的事情时,我得到"没有指定输入文件".我的Homestead.yaml文件如下所示:
authorize: /Users/me/.ssh/id_rsa.pub
keys:
- /Users/me/.ssh/id_rsa
folders:
- map: /Users/me/code/exampleproject
to: /home/vagrant/code/exampleproject
sites:
- map: exampleproject.app
to: /home/vagrant/code/exampleproject/public
variables:
- key: APP_ENV
value: local
Run Code Online (Sandbox Code Playgroud)
在我的电脑上,我有以下目录:
/Users/me/code/Homestead
/Users/me/code/exampleproject //this is the directory created with composer
Run Code Online (Sandbox Code Playgroud)
在我的Vagrant Box上我出于某种原因有两个名为"code"和"Code"的目录:
/home/vagrant/code/exampleproject
/home/vagrant/Code
Run Code Online (Sandbox Code Playgroud)
我已经检查过,我可以看到对我的计算机exampleproject文件所做的更改反映在vagrant box文件中.
不太确定如何解决这个问题!我真的很感激任何可能的帮助:)
我想将一个回调传递给一个双重嵌套的组件,虽然我能够有效地传递属性,但我无法弄清楚如何将回调绑定到正确的组件以便它被触发.我的结构看起来像这样:
-OutermostComponent
-FirstNestedComponent
-SecondNestedComponent
-DynamicallyGeneratedListItems
Run Code Online (Sandbox Code Playgroud)
单击列表项时应触发回调,即OutermostComponents方法"onUserInput",但我得到"未捕获错误:未定义不是函数".我怀疑问题在于我如何在第一个内部渲染SecondNestedComponent,并将其传递回调.代码看起来像这样:
var OutermostComponent = React.createClass({
onUserInput: //my function,
render: function() {
return (
<div>
//other components
<FirstNestedComponent
onUserInput={this.onUserInput}
/>
</div>
);
}
});
var FirstNestedComponent = React.createClass({
render: function() {
return (
<div>
//other components
<SecondNestedComponent
onUserInput={this.onUserInput}
/>
</div>
);
}
});
var SecondNestedComponent = React.createClass({
render: function() {
var items = [];
this.props.someprop.forEach(function(myprop) {
items.push(<DynamicallyGeneratedListItems myprop={myprop} onUserInput={this.props.onUserInput}/>);}, this);
return (
<ul>
{items}
</ul>
);
}
});
Run Code Online (Sandbox Code Playgroud)
如何正确地将回调绑定到适当的嵌套组件?
我有一个我在React.js和Zurb Foundation建立的进度条,我想反映当前的状态.我知道在开始时我可以用这样的东西设置宽度:
render: function() {
var spanPercent = (this.props.a - this.props.b)/this.props.a + '%';
var spanStyle = {
width: spanPercent
};
return (
<div className="progress">
<span className="meter" style={spanStyle}></span>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
但是,当props的值因状态更改而发生更改时,即使props值发生更改,内联样式也不会更新.这样做是否有最佳实践,例如使用回调或将代码放在其他位置?我将不胜感激任何帮助!
我正在学习使用react和mapbox,但我正在努力解决为什么我的mapbox地图在通过React加载时无法正确呈现.当我正常加载它(没有React.js)时,没有问题,因为下面的代码工作并且地图正常显示:
<script src="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js"></script>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css"/>
<div> id="map"></div>
<script>
var map = L.mapbox.map('map', 'blabla.blabla').setView([lat, long], 9);
</script>
Run Code Online (Sandbox Code Playgroud)
但是当我按照以下方式进行操作时,地图通常根本不显示,或者当它出现时,我只看到div左上角的一部分.
<script src="path/to/react.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js"></script>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css"/>
<div id="react-content">
<script src="path/to/react/content.js'></script>
</div>
//now inside react/content.js, there is a mapbox component inside an outer component. I'm leaving out the rest of the code to save space, and I believe that I am rendering the OuterComponent and the MapBoxMap component correctly inside that.
var MapBoxMap = React.createClass({
componentDidMount: function() {
L.mapbox.accessToken = this.props.accessToken;
var …
Run Code Online (Sandbox Code Playgroud)