- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码在 Edge 和 Internet Explorer 中的 CSS 和应用中断-
componentDidMount() {
const styles = require('./GettingStarted.scss');
document.getElementById('bodyTag').classList = '';
document.getElementById('bodyTag').classList.add(styles.GettingStartedContainerBody);
document.getElementById('content').classList.remove(styles.AppContainerBody);
document.getElementById('content').classList = '';
document.getElementById('content').classList.remove(styles.AppContainerBodyWithoutLogin);
}
componentWillReceiveProps(nextProps) {
if (!this.props.checked && nextProps.checked) {
let queryString = '';
const windowLocation = window.location.href;
const queryStringStartIndex = windowLocation.indexOf('?');
if (queryStringStartIndex > 0) {
queryString = windowLocation.substring(queryStringStartIndex,windowLocation.length);
}
if(nextProps.result[0].status === '0') {
browserHistory.push(config.BASE_URL + '/userdetail' + queryString);
} else if(nextProps.result[0].status === '1') {
browserHistory.push(config.BASE_URL + '/signuplogin' + queryString);
}
}
}
render() {
const { checking, checkingError, fields: {emailid}} = this.props;
const styles = require('./GettingStarted.scss');
const pmdLogo = require('../../../static/plexusmd-logo.png');
return (
<div className={styles.gettingStartedPage}>
<Helmet {...config.app.head} title="Getting Started | PlexusMD" />
<div className="gettingStartedForm margin-top-bottom-40">
<div className="headerLogoMenuContainer text-center margin-bottom-30">
<IndexLink className="brandlogo" to={config.BASE_URL + '/gettingstarted'} >
<img className="brand" src={pmdLogo} width="80" height="25" title={config.app.title} alt={config.app.title} />
</IndexLink>
</div>
<form className="form" onSubmit={this.handleSubmit} >
<h2 className="orange font22 text-left text-bold text-uppercase margin-top-0 margin-bottom-50 margin-left-right-20">Getting started</h2>
<div className="form-group">
<label htmlFor="password" className="control-label gray">What's your Email address?</label>
<div className="input-group">
<input type="text" id="emailid" name="emailid" ref="emailid" placeholder="Email address" value={this.props.emailid} className="form-control text-lowercase" {...emailid}/>
{!emailid.error && <span id="emailid" className="input-group-addon input-group-icon"><i className="icon ion-ios-checkmark-empty icon-size green"/></span>}
{ emailid.error && emailid.dirty && <div id="emailid" className="red smaller margin-0-auto">Enter a valid Email</div>}
</div>
</div>
<div className="form-group">
<div className="text-right">
{checkingError && <p className="loginError red text-left">{checkingError}</p>}
{!checking && <button className="btn btn-primary" onClick={this.handleSubmit.bind(this)} disabled={emailid.error}>NEXT
</button>}
{checking && <button className="btn btn-primary" disabled={checking}>WAIT</button>}
</div>
</div>
<div className="clear"></div>
</form>
</div>
<div className="clear"></div>
</div>
);
}
此页面的背景颜色没有更新,输入字段也被禁用,即,除非我删除 <input>
中的 Prop ,否则无法输入该字段标签。
AppContainerBody
和 AppContainerBodyWithoutLogin
css 类继承自 app.scss
. GettingStartedContainerBody
类列表属于 GettingStarted.scss
我在我的 React 应用程序中的几乎每个文件中都添加了这些类列表。该应用程序在 Chrome、Firefox 和 Safari 中运行良好,但我在控制台中收到此错误:
Unhandled promise rejection TypeError: Assignment to read-only properties is not allowed in strict mode
Link到应用程序和App.scss和 GettingStarted.scss .
版本: react :0.14.2
边缘:40.15063.674.0
最佳答案
将函数中的所有 require 语句移至文件顶部。
因此,不要在每个要使用样式的函数中调用 const styles = require('./GettingStarted.scss');
,只需导入一次即可。
喜欢:
require('./GettingStarted.scss');
// or
import './GettingStarted.scss';
classList
不能直接改变。使用 classList.add
和 classList.remove
或通过 className = ''
或 .setAttribute( 'class', '' )
还尝试通过将选择保存到变量来尽量减少 DOM 选择/代码重复,例如:
const bodyTag = document.getElementById('bodyTag');
// further instructions for #bodyTag
const content = document.getElementById('content');
// further instruction for #content
关于javascript - react : CSS breaks using classList in IE and Edge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47034181/
我不明白为什么我使用的 classList.toggle 的行为类似于 classList.add。当我单击具有下拉菜单的列表项时,它只会在第一次单击时进行更改,而在第二次单击时不会进行任何更改。 v
我有一个元素列表 (ul, li),其中一个类在您单击该元素时设置左边框和粗体突出显示。 当您单击列表中的不同项时,我想将样式重置为原始项,使其恢复正常,然后在刚刚单击的事件项上设置新样式。 奇怪的是
正如标题所说。我似乎看不出两者之间的区别,也看不出 toggle 的第二个参数有什么意义。 谁能给我解释一下? 最佳答案 没有区别; toggle 的第二个参数是为了让这种事情更方便: if (h
这个问题在这里已经有了答案: How can a read only property(element.classList) can be modified or assigned to some
我有一个“+”按钮,单击该按钮时,会触发创建一个带有输入和 2 个按钮的 block ,一个用于验证输入,一个用于删除输入。 //我的代码看起来几乎像这样: addBtn.addEventLi
我试图通过创建具有 3 个执行上下文的堆栈来制作执行堆栈如何在 Javascript 上工作的原理图。全局、执行 A 和执行 B。为此,我构建了一组嵌套的 div 并添加了一个 displayNone
我正在努力提高我的 JavaScript 技能,但我无法解决这个问题。我想在 button.terug 时在我的 body 中显示图像被点击。 我尝试使用 classList.toggle()切换类名
这是我使用 .classList.contains() 时遇到的错误 Uncaught TypeError: Cannot read property 'contains' of undefined
我正在尝试使用 js 和 css 创建一个简单的选项卡式功能。单击选项卡按钮时,它应该从控件中删除所有 active 类,然后仅将 active 类添加到所选元素。 但是,当我尝试删除 active
所以这个程序的重点是询问学生他们的名字,他们这学期上了多少门课,然后它要求每门课的名字。我的问题是我无法让 classList 数组工作并在程序输出中将类名显示给用户。我已经标记了我认为问题的来源,我
我正在尝试做一个简单的 slider ,但我遇到了这个问题: Uncaught TypeError: Cannot read property 'classList' of undefined 这是我
我试图根据变量是否等于 0 添加和删除一个类。这是我的代码: import { LitElement, html } from 'lit-element'; class SelectCounter e
下面是通过 DOM 获取一些元素的代码片段。我只是附加一个简单的 onclick,它应该将“隐藏”属性添加到每个检索到的元素的 classList 中。 HTML: Explorin
我正在尝试创建一个循环,每次执行时都会更改元素的类 HTML Random JS const all_buttons = document.getElementsByTagName('button
我尝试使用 classList.contains 搜索特定类的 DOM 元素,但出现此错误: "TypeError: Cannot read property 'contains' of undefi
我尝试使用 classList.remove 显示测验结果,但这不起作用。 这是我的 HTML。结果位于一个 div 内,该 div 内还有 5 个具有类的其他 div。这个想法是,当提交答案时,其中
我想在调整浏览器大小时删除特定屏幕尺寸上的单击事件监听器。 问题是下面的代码在我刷新页面并且期望的结果就在那里的情况下工作。然而,在调整浏览器大小时,它会保持在低于所需宽度时可点击或超过所需宽度时不可
我试图让扩展面板仅在点击箭头时展开,但是当我尝试编译它时,此功能 private _isExpansionIndicator(target: EventTarget): boolean { c
我有一个像这样的元素: 我想删除所有以“bg-color-”开头的类,所以我只需循环遍历所有类,然后删除匹配的类: var element = document.getElement......;
我在使用 classList.toggle 和 Font Awesome 图标时遇到了一个非常令人困惑的问题。我希望我的汉堡菜单在单击时更改为 X,并且我正在尝试使用 JavaScript 函数来完成
我是一名优秀的程序员,十分优秀!