我编写此代码作为工厂模式的实践,但出现错误并且我不知道为什么。代码:class ShopFactory {constructor (item, type, name) {let shelf;if(type === "toiletries"){shelf = new Toiletries(item, name);}else if (type === "cosmetics") {shelf = new
2021-07-24
下面的 JavaScript 在<script> JS </script>标记内运行时运行良好。但是,当我从单独的文件运行代码时,我收到 Uncaught TypeError:无法将 innerHTML 属性设置为 null。我不知道这里发生了什么。任何帮助都非常感谢。// Admin Nightmode Switchvar nmStylesheet = document.getElementBy
2021-07-06
在我的Something.vue中:<template><p>{{ codes }}</p></template>export default {data() {return {codes: 'test'}},name: 'Functions',props: {msg: String},setup() {this.codes = 'does it work?';}</script><style><
我正在尝试使用Froala 富文本编辑器的 React 版本另请参阅react-froala-wysiwyg。我创建了一个简单的编辑器组件,如下所示import { string } from 'prop-types'// note the docs say do this// import 'froala-editor/js/froala_editor.pkgd.min.js'// but th
2021-06-25
我的 JS 代码如下所示。但是当我打开页面时,它显示“未捕获 TypeError:无法将属性“innerHTML”设置为 null”我尝试将 NewItem 构造函数更改为函数。但是 VSC 一直说我应该将其声明为类。我首先将其转换,因为构造函数也不能作为函数工作。class NewItem {constructor(name, date, price) {this.itemName = name
2021-06-22
我使用“npm link my-package”重定向我的 node_module。但我无法使用“vite dev”成功运行。Vite 无法解析我的本地私有包。Uncaught TypeError: Cannot set property 'my-package' of undefined.但是,如果我从 npm 服务器使用“npm i my-package”,它可以工作。操作系统:windows
我想使用 JavaScript 操作(添加/删除行)html 中的两个表。使用一个表时可以,但如果添加第二个表,则会收到此错误:Uncaught TypeError: Cannot set property 'innerHTML' of null更准确地说:我想根据单击的按钮,分别拥有两个表,每个表包含不同的内容。使用一个表时可以。第一个函数删除表内容 -> 添加新内容。第二个函数相同,从第一个表
2021-06-12
我想使用 JS 将此 HTML 块插入到另一个 HTML 文件中,因为如果我需要编辑导航,我只需在 JS 文件中编辑它即可:<div class="navbar"><div class="dropdown"><div class="dropbtn" id="dropbtn"><a id="menu"><img src="files/i/menu.svg" width="30"></img><spa
2021-05-25
<html><body><p>maximum number:<input type="text" id="number"></p><p>how many questions?<input type="text" id="questions"></p><button onclick="button()"> ok </button><div id = 'div'> </div><div id = 'd
2021-05-05
我找不到问题所在。我只是收到“Uncaught TypeError:无法设置未定义的属性‘display’”这个错误。function filterTodo(e){const todos = todoList.childNodes;todos.forEach(function(todo){switch (e.target.value){case "all" :todo.style.display
2021-05-04
我在我的所有其他网站上都正常执行了此操作,但出于某种原因,它不起作用,这是我的 javascript:document.getElementById("time").innerText = "test";这是我的 HTML:<div id="time"></div>我不明白为什么它不起作用,因为它在我的所有其他项目中都有效。这是我收到的错误消息:Uncaught TypeError: Cannot
2021-04-30
我的 html 文件中有一个侧边栏,我想在其中放置各种内容。但是,我真的无法将所有内容都放进去。我想隐藏父 divside-bar中的默认子元素。起初,我尝试创建一个循环,遍历所有子元素并将其样式更改为style.display = 'none';。这没有奏效。我收到错误消息:code.js:128 Uncaught TypeError: 无法设置未定义的属性“display”我目前要实现目标的代
2021-04-24
我尝试在将鼠标悬停在 div 上时显示 div 中的按钮并隐藏其中的文本,然后隐藏按钮但显示 div 的文本。我一直收到未定义的错误。我做错了什么?Error:coreScript.js:12 Uncaught TypeError: Cannot set property 'display' ofundefinedat showButton (coreScript.js:12)at HTMLDiv
2021-04-19
我希望用户能够记录他们执行的操作。我按类别对操作进行分组,然后使用两个选择菜单和 JS 仅向用户显示他们所选类别的操作。还有一个数量输入,它根据所选操作生成。我的问题是,当我提交表单时,我收到错误:未捕获的 TypeError:无法将属性“onchange”设置为 null选择框和 JS 实现的功能在提交表单之前有效。index.jsdocument.addEventListener("DOMCo
2021-04-12
大家好,我希望从你们高超的技能水平经验中找到一些答案。我正在填充这个我知道如何做的 2D 数组,但我收到此错误:script.js:35 未捕获的类型错误:无法设置未定义的属性“0”at script.js:35当我单击控制台中的错误时,它指向本例中第 9 行的数字 2:gameArray[row][column]= 2;我应该将数组声明为整数数组吗?为什么我不能使用 gameArray[row]
2021-03-25