Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loading] 使用 Api 的方式调起 loading 动画指定 dom,报错:Uncaught TypeError: Cannot read properties of null (reading 'appendChild') #3360

Open
chinawangyatao opened this issue Feb 8, 2025 · 2 comments
Labels
💭 discussion we are discussing example Something about example

Comments

@chinawangyatao
Copy link

chinawangyatao commented Feb 8, 2025

tdesign-react 版本

"tdesign-react": "^1.10.0",

重现链接

No response

重现步骤

const loadInstance = loading({
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-expect-error
  attach: () => document.querySelector('#subApp'),
  showOverlay: true,
  zIndex: 599,
  size: 'small',
  text: '加载中...',
  style: {
    width: '100%',
    height: '100%',
    backdropFilter: 'blur(4px)',
  },
})
const loader = (loadingStatus?: boolean) => {
  if (!loadingStatus) {
    setTimeout(() => {
      loadInstance.hide()
      start()
    }, 500)
  }
  console.log('loading:', loadingStatus)
}

期望结果

不报错

实际结果

Image

框架版本

{
  "name": "sass-base",
  "version": "0.1.0",
  "homepage": "/wly-base",
  "private": true,
  "dependencies": {
    "@reduxjs/toolkit": "2.2.7",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.119",
    "@types/nprogress": "^0.2.3",
    "@types/react": "^18.3.12",
    "@types/react-dom": "^18.3.1",
    "@types/react-redux": "^7.1.34",
    "@types/react-router-dom": "^5.3.3",
    "@types/react-transition-group": "^4.4.12",
    "@types/webpackbar": "^4.0.6",
    "axios": "^1.7.7",
    "less-loader": "^6.2.0",
    "nprogress": "^0.2.0",
    "qiankun": "^2.10.16",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-full-screen": "^1.1.1",
    "react-redux": "9.1.2",
    "react-router": "^7.0.1",
    "react-scripts": "5.0.1",
    "react-transition-group": "^4.4.5",
    "redux-persist": "6.0.0",
    "tdesign-icons-react": "^0.4.2",
    "tdesign-react": "^1.10.0",
    "typescript": "^4.9.5",
    "web-vitals": "^2.1.4",
    "webpack": "^5.96.1",
    "webpackbar": "^7.0.0"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "build:prod": "cross-env NODE_ENV=production craco build",
    "build:test": "cross-env NODE_ENV=test craco build",
    "test": "craco test",
    "eject": "craco eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@craco/craco": "^7.1.0",
    "@craco/types": "^7.1.0",
    "@eslint/js": "^9.15.0",
    "@typescript-eslint/eslint-plugin": "^7.0.0",
    "@typescript-eslint/parser": "^7.0.0",
    "craco-less": "^3.0.1",
    "cross-env": "^7.0.3",
    "eslint": "^8.0.0",
    "eslint-config-airbnb-typescript": "^18.0.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "eslint-plugin-react": "^7.37.2",
    "globals": "^15.12.0",
    "less": "^4.2.0",
    "prettier": "^3.3.3",
    "tailwindcss": "^3.4.15",
    "typescript-eslint": "^8.15.0"
  }
}

浏览器版本

No response

系统版本

No response

Node版本

node:18

补充说明

No response

Copy link
Contributor

github-actions bot commented Feb 8, 2025

👋 @chinawangyatao,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@HaixingOoO
Copy link
Collaborator

可以的话提供你使用的例子导致的bug,看报错你要确定你执行loading api时,dom已渲染了可以找到了

@HaixingOoO HaixingOoO added the example Something about example label Feb 11, 2025
@HaixingOoO HaixingOoO added the 💭 discussion we are discussing label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💭 discussion we are discussing example Something about example
Projects
None yet
Development

No branches or pull requests

2 participants