【发布时间】:2018-01-26 05:16:13
【问题描述】:
在我的渲染方法内部,我正在调用一个基于 API 响应数据执行一些条件逻辑的方法。考虑到我没有从 DOM 中删除任何内容,我不清楚如何解决此错误。这是我的方法
import numeral from 'numeral';
import moment from 'moment';
class SearchResultsListItem extends React.Component {
constructor(props) {
this.isMaxQtyGreaterThanOneThousand=
::this.isMaxQtyGreaterThanOneThousand;
}
isMaxQtyGreaterThanOneThousand(qty){
if(!!qty){
if(qty%1000 === 0){
return (numeral(qty).divide(1000).format('0,000') + 'M');
}else{
return numeral(qty);
}
}else{ return "-";}
}
render() {
const x = this.props.dataItem;
return (
<div className={`${s['quantity-block']}`}>
{this.isMaxQtyGreaterThanOneThousand(x.MaxQuantity)}
</div>
)
}
为了解决这个错误,我查看了以下帖子,但没有找到任何特定于 jsx 或 React 的内容:
Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'
【问题讨论】:
标签: javascript reactjs conditional jsx