此处将为大家介绍关于使用Javascript和CSS的ReactJs模式的详细内容,并且为您解答有关cssinjsreact的相关问题,此外,我们还将为您介绍关于ff与ie对javascript和cs
此处将为大家介绍关于使用Javascript和CSS的ReactJs模式的详细内容,并且为您解答有关css in js react的相关问题,此外,我们还将为您介绍关于ff与ie对javascript和css的区别、IE8中使用javascript动态加载CSS的解决方法_javascript技巧、javascript – ReactJs – 可重用的Redux服务、javascript – ReactJS:JSX属性名称的模式的有用信息。
本文目录一览:- 使用Javascript和CSS的ReactJs模式(css in js react)
- ff与ie对javascript和css的区别
- IE8中使用javascript动态加载CSS的解决方法_javascript技巧
- javascript – ReactJs – 可重用的Redux服务
- javascript – ReactJS:JSX属性名称的模式
使用Javascript和CSS的ReactJs模式(css in js react)
如何将带有主体结束标签的reactjs模态窗口追加到带有主体标签的模态定位绝对值中。
这是在另一个组件内添加的示例。
<div className="modal"> <p>Model Pop-up <button onClick={this.handleClick}>here</button></p> <div id="js-modal-inner" className="modal"> <div className="modal__content js-dialog"> <a className="modal__close" onClick={this.handleClose}>×</a> <header className="modal__header"> <h2 className="modal__title">Split Ticket:</h2> </header> <div className="modal__content--inner"> {this.props.children} </div> </div> </div> <div className="modal__overlay js-fade"></div> </div>
答案1
小编典典在反应中,这通常称为“层”。看到这个小提琴
/** @jsx React.DOM */var ReactLayeredComponentMixin = { componentWillUnmount: function() { this._unrenderLayer(); document.body.removeChild(this._target); }, componentDidUpdate: function() { this._renderLayer(); }, componentDidMount: function() { // Appending to the body is easier than managing the z-index of everything on the page. // It''s also better for accessibility and makes stacking a snap (since components will stack // in mount order). this._target = document.createElement(''div''); document.body.appendChild(this._target); this._renderLayer(); }, _renderLayer: function() { // By calling this method in componentDidMount() and componentDidUpdate(), you''re effectively // creating a "wormhole" that funnels React''s hierarchical updates through to a DOM node on an // entirely different part of the page. React.renderComponent(this.renderLayer(), this._target); }, _unrenderLayer: function() { React.unmountComponentAtNode(this._target); }};var Modal = React.createClass({ killClick: function(e) { // clicks on the content shouldn''t close the modal e.stopPropagation(); }, handleBackdropClick: function() { // when you click the background, the user is requesting that the modal gets closed. // note that the modal has no say over whether it actually gets closed. the owner of the // modal owns the state. this just "asks" to be closed. this.props.onRequestClose(); }, render: function() { return this.transferPropsTo( <div className="ModalBackdrop" onClick={this.handleBackdropClick}> <div className="ModalContent" onClick={this.killClick}> {this.props.children} </div> </div> ); }});var ModalLink = React.createClass({ mixins: [ReactLayeredComponentMixin], handleClick: function() { this.setState({shown: !this.state.shown}); }, getInitialState: function() { return {shown: false, ticks: 0, modalShown: false}; }, componentDidMount: function() { setInterval(this.tick, 1000); }, tick: function() { this.setState({ticks: this.state.ticks + 1}); }, renderLayer: function() { if (!this.state.shown) { return <span />; } return ( <Modal onRequestClose={this.handleClick}> <h1>Hello!</h1> Look at these sweet reactive updates: {this.state.ticks} </Modal> ); }, render: function() { return <a href="javascript:;" role="button" onClick={this.handleClick}>Click to toggle modal</a>; }});React.renderComponent(<ModalLink />, document.body);
ff与ie对javascript和css的区别
随着互联网的不断发展,网页开发成为了人们生活中不可或缺的一部分。网页开发中使用的javascript和css语言也变得越来越重要。而对于不同的浏览器,它们对javascript和css的解释和实现也存在一些差异。本文将着重讨论ff和ie对javascript和css的区别。
一、JavaScript的区别
- 事件处理器
FF和IE的事件处理器有一些差别。FF不支持通过特定方式在一个元素上覆盖事件处理器。而IE则可以通过使用DOM元素的“AttachEvent”方法覆盖原来的事件处理器。
- 对象属性的访问
在JavaScript中,对象的属性可以通过两种方式进行访问:直接引用对象属性和使用方括号操作符。但是在IE浏览器中,当对象属性的名称与已有的全局变量名称相同时,通过直接引用对象属性访问时会出现问题。
- 操作符顺序
FF和IE对于JavaScript的操作符顺序的处理也存在差别。在JavaScript中,操作符顺序决定了语句的执行顺序。而在IE浏览器中,对于操作符优先级的处理会与其他浏览器存在差异。
立即学习“Java免费学习笔记(深入)”;
- 对象属性的枚举顺序
在JavaScript中,对象属性的枚举顺序是未定义的。但是在IE浏览器中,对象的属性会按照特定的顺序被枚举出来。
二、CSS的区别
- 盒子模型
在CSS中,盒子模型是非常重要的一个概念。但是在FF和IE中,盒子模型的实现存在差异。在FF中,盒子模型会默认采用“标准模型”,即元素的宽度和高度不包含边框和内边距。而在IE中,默认采用的是“传统模型”,即元素的宽度和高度包含边框和内边距。
- CSS选择符
在CSS中,选择符的使用非常广泛。但是在FF和IE中,对于一些选择符的支持也存在差异。例如,FF支持CSS3中的属性选择器,在IE中需要使用JavaScript来实现。
- 解释CSS的方式
FF和IE对CSS的解释方式也存在差异。在FF中,CSS的解释过程是非常严格的,对于任何错误都不会进行容错。而在IE中,会存在一些容错机制,可以允许一些错误的CSS语法通过。
- 样式表的缓存
在CSS样式表文件被请求时,浏览器会进行缓存,以提高页面加载的速度。但是在FF和IE中,对于缓存的处理也存在差异。在FF中,如果样式表的URL发生了变化,浏览器会清除缓存并重新加载。而在IE中,如果样式表的URL未发生变化,即使样式表本身发生了变化,浏览器也会使用缓存中的旧样式表进行解释。
综上所述,随着互联网的不断发展,网页开发越来越重要。而掌握不同浏览器对JavaScript和CSS的差异也显得非常必要。所以,在进行网页设计时,我们还需要考虑到不同浏览器的兼容性问题。
以上就是ff与ie对javascript和css的区别的详细内容,更多请关注php中文网其它相关文章!
IE8中使用javascript动态加载CSS的解决方法_javascript技巧
众所周知做前端开发的都恨不得踹IE开发者几脚,IE开发者名声之差不低于GFW开发者,昧着良心搞坏市场,人人得而诛之,但是在中国这些地方市场占有率摆在那里,没办法只能向现实低头。
最近我们产品需要在浏览器里动态载入一段CSS,以前的代码是直接用的:
var bubbleCss = document.createElement(''style'');
bubbleCss.type = ''text/css'';
bubbleCss.innerHTML = blc_conf.bubbleStyle;
document.getElementsByTagName(''head'')[0].appendChild(bubbleCss);
不过这个只有IE9支持,在IE8下会出问题,一直也没注意到这块,直到最近重构后做完整测试的时候才发现。
网上搜到一个技巧,试过,可行,但是有一些问题
window.bc_bubble_css = blc_conf.bubbleStyle;
document.createStyleSheet("javascript:bc_bubble_css");