我是Web开发的新手,这只是我创建的一个简单的代码,用于测试我安装的新文本编辑器,我在尝试导入react时遇到了此错误,因为我遇到了一些其他错误,例如;类型错误: 无法读取未定义的属性“createElement”
请问,我该如何解决这个问题?导入语句有误吗?
import React, { Fragment } from 'react';
console.log("Testing");
var document;//made this declaration because I got a document undefined error
document.createElement("p"):
const p = document.createElement("p")
p.innerHTML = "This is to test the javascript";
const body = document.querySelector("body");
body.insertBefore(p,body.childNode[-1]);
<!DOCTYPE html>
<html>
<head>
<title>Testing vs code</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<h1>Testing the vscode html preview package</h1>
<h2>Hello</h2>
<script type="module" src="js-prac.js"></script>
</body>
</html>
隔江千里
LEATH
犯罪嫌疑人X
相关分类