gpt4 book ai didi

javascript - ./src/index.js第10行: 'elementid' is not defined no-undef

转载 作者:行者123 更新时间:2023-12-02 10:56:22 25 4
gpt4 key购买 nike

import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter} from "react-router-dom";
import * as serviceWorker from './serviceWorker';
import App from '/App';

ReactDOM.render(
<BrowserRouter>
<App/>
</BrowserRouter>, document.getElementById(elementid, 'root'));
serviceWorker.unregister();
我只是在reactjs的index.js文件中键入此代码,然后会发生此错误
Failed to compile
./src/index.js
Line 10: 'elementid' is not defined no-undef

Search for the keywords to learn more about each error.
所以请告诉我,该如何解决此错误

最佳答案

React Dom Render需要元素引用,因此您必须使用document.getElementById('root')提供引用。只需删除elementid

关于javascript - ./src/index.js第10行: 'elementid' is not defined no-undef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63042482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com