Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

demo里面可以渲染DOM,js文件呢? #3

Open
manwuyu opened this issue Jul 21, 2016 · 3 comments
Open

demo里面可以渲染DOM,js文件呢? #3

manwuyu opened this issue Jul 21, 2016 · 3 comments

Comments

@manwuyu
Copy link

manwuyu commented Jul 21, 2016

No description provided.

@alphatr
Copy link
Owner

alphatr commented Jul 21, 2016

@manwuyu 可以具体描述下遇到的问题么

@manwuyu
Copy link
Author

manwuyu commented Jul 22, 2016

你的demo 是可以渲染出DOM元素的,但是app.jsx文件中的事件不知道在哪?
比如 下面是我的jsx文件
其中handleChange ,handleClick,handleFocus三个方法没有了

var React = require('react'); module.exports = React.createClass({ displayName: 'App', getInitialState: function () { return ({ isShow: true, inputText: "placeholder" }); }, render: function() { var style = { display: this.state.isShow ? "block" : "none" }; return ( <div> <div> <input type="text" value={this.state.inputText} onChange={this.handleChange} ref="destination" /> <button onClick={this.handleFocus}>聚焦</button> <button onClick={this.handleClick}>显示/隐藏</button> </div> <p style={style}>{this.state.inputText}</p> </div> ); }, handleChange: function(e) { this.setState({ inputText: e.target.value }); }, handleClick: function() { this.setState({ isShow: !this.state.isShow }); }, handleFocus: function() { this.refs.destination.focus(); } });

@alphatr
Copy link
Owner

alphatr commented Jul 22, 2016

这个组件是用于服务端渲染,服务端渲染不会将前端的事件渲染出来,这是服务端渲染这种方式所决定的,服务端渲染完成后需要通过前端代码重新初始化 React App

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants