前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >一个属性引发的React报错:The above error occurred in the component

一个属性引发的React报错:The above error occurred in the component

作者头像
德顺
发布2023-08-25 13:25:38
5360
发布2023-08-25 13:25:38
举报
文章被收录于专栏:前端资源前端资源

程序运行报错:

代码语言:javascript
复制
devScripts.js:6523 The above error occurred in the <div> component:

    at div
    at IndexPage
    at IndexPage
    at div
    at IndexPage
    at LoadableComponent (http://localhost:8130/mf-dep_vendors-node_modules_babel_runtime_helpers_esm_extends_js-node_modules_babel_runtime_helpers_-424ef3.f230f37e.async.js:474:68)
    at Route
...

代码部分:

代码语言:javascript
复制
import React from 'react';
import styles from './index.less';

const IndexPage: React.FC<{}> = () => {
  return (
    <div className={styles.titleHead}>
      <div className={styles.titleName}>板块</div>
      <div className={styles.titleInfo}>
        <div className={styles.tabControl}>
          <div style={styles.tabItem}>累计</div>

        </div>
      </div>
    </div>
  );
};
export default IndexPage;

很难发现,累计一行, div 属性应该是 className ,这里错写成了 style 所以引发了报错。

style 的属性应该是一个 {}

未经允许不得转载:w3h5-Web前端开发资源网 » 一个属性引发的React报错:The above error occurred in the component

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-01-04),如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档