我正在创建我的第一个电子反应应用程序(我的第一个电子应用程序).我有两条路线需要从一条路线导航到另一条路线.为此,我使用以下代码:
根
ReactDOM.render(
<Router history={browserHistory}>
<App />
</Router>,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
应用
class App extends React.Component {
constructor() {
super();
}
render() {
return (
<div className="app-master">
<Switch>
<Route path='/city' component={CityList}/>
<Route path='/' component={SplashScreen}/>
</Switch>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
页
import { browserHistory } from 'react-router';
...
browserHistory.push('/city');
Run Code Online (Sandbox Code Playgroud)
这条线给出错误,
TypeError: Cannot read property 'push' of undefined
Run Code Online (Sandbox Code Playgroud)
我在网上搜索可能的解决方案,但找不到一个!关于SO也有很多类似的问题,但没有一个对我有用:(
以下是PropTypes的示例:
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
Run Code Online (Sandbox Code Playgroud)
现在我使用Greeting组件:
<Greetings otherProp="this is a invalid prop" />
Run Code Online (Sandbox Code Playgroud)
在这种情况下,当我构建应用程序以进行部署时,不会抛出任何错误并成功构建应用程序.但它会在运行时出错并发生故障.
如何添加检查以消除此问题并确保没有使用错误的prop类型构建组件.
您好,有一个 proto 文件,如下所示:
enum Type
{
A = 0;
B = 1;
C = 2;
}
message Message
{
User to = 1;
User from = 2;
Type type = 3;
}
Run Code Online (Sandbox Code Playgroud)
我使用protoc编译器将其转换为 javascript 实用程序类。使用这个生成的 javascript 文件,我在我的应用程序中设置了 Message 对象,如下所示:
const message = new Main.Message()
message.setTo(this.user1) // saved user
message.setFrom(this.user3) // saved user
message.setType(0) // trying to set type to A
const buffer = message.serializeBinary()
socket.send(buffer)
Run Code Online (Sandbox Code Playgroud)
我面临的问题是消息对象to和from字段都得到了正确更新,但type仍然存在null!我无法为此找到解决方案。
这是因为在Messageproto 中,预期类型是 …
我最近将我的Xcode更新到了5.1版.更新后,它可以在除iOS 7.1之外的所有模拟器上正常运行,其中会出现mach-O链接错误.此外,"构建设置"选项卡中只有64位架构选项.据我所知,这是所有问题和错误的原因.有谁知道这个的原因以及如何解决它?
以下是我收到的一些警告和错误:
警告 :
Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead
Run Code Online (Sandbox Code Playgroud)
错误:
Symbol(s) not found for architecture x86_64
Run Code Online (Sandbox Code Playgroud)
谢谢.
是否有css属性可以限制div中显示的字符数。例如
<div class ="main-text">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, …Run Code Online (Sandbox Code Playgroud) 我试图同时设置多个状态属性,但由于我setState()是异步的,我将使用回调,但作为更多的属性,我必须一次编辑这个代码变得越来越难看!
有没有其他好方法来实现这一目标?
this.setState(
{
item_1: true
},
(e => {
this.setState(
{
item_2: false
},
(e => {
this.setState(
{
item_3: 'Hello World'
}
)
})
)
})
)
Run Code Online (Sandbox Code Playgroud)