本文主要是介绍npm run start启动时提示 A decorated export must export a class declaration报错,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题描述:
基于react开发的项目在启动过程中,提示 A decorated export must export a class declaration报错,如下图所示:
解决办法:
上面是一个react hoc高阶组件,es6装饰器的语法是要包裹class组件的,所以要改成以下这种写法就ok了;
export default function WithOperateTab(WrappedComponent) {@withRouter@withAliveScopeclass WrapperComponent extends PureComponent {openTab = (url) => {if (url) {const { tabKey } = getKeyName(url)this.props.history.push(url)setTimeout(() => {const cachingNodes = this.props.getCachingNodes(tabKey)if (cachingNodes.find((item) => item.cacheKey === tabKey)) {this.props.refresh(tabKey)}}, 100)}}}return WrapperComponent;
}
这篇关于npm run start启动时提示 A decorated export must export a class declaration报错的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!