我正在编写一个简单的脚本,该脚本循环遍历页面上的所有元素,并使用原生 JavaScript 共享它们。以下是我目前所拥有的var buttons = document.getElementsByClassName('share-gray-large');for(var i=0; i<buttons.length; i++){buttons[i].click();document.getElemen
2021-03-20
我正在使用 matter.js 和 p5.js 制作这款游戏,你必须使用弹弓和石头让芒果从树上掉下来。代码看起来有点像这样:SlingShot.js: constructor(bodyAInput, pointBInput) {var options = {bodyA: bodyAInput,pointB: pointBInput,stiffness: 0.2,length: 20}th
2021-03-19
我有一个 api,我想从中显示数据,我有 2 个数组,每个数组都有一个类别,我将如何迭代并显示这两个类别,即艺术类别和娱乐类别。我尝试了一些方法,但没有奏效,它给出了这个错误TypeError:无法读取未定义的属性“map”,非常感谢您的帮助。提前致谢import React,{useState, useEffect} from 'react'import './Home.css'import B
2021-03-17
我想添加一个函数来检查购物车是空的还是已装满的,并根据此逻辑显示输出。如果 cart.line_items.length 不为真,则应运行 EmptyCart 函数。请注意,“line_items”是来自 API 响应的数组。然后它应该循环遍历每个项目并在material-ui网格中显示该项目。这是我的 .jsx 代码。import React from 'react';import { Cont
2021-03-06
大家好,我有一个项目,它从 API 获得响应,然后将数据从父级传递到子级。问题是,我可以轻松访问顶层的响应,但当我尝试进入 API 的内部部分(在本例中为price={statistics.quotes.USD.price)时,我收到了TypeError: Cannot read property 'USD' of undefined错误。我尝试使用 console.logging 价格来检查我的
2021-03-02
我正在制作一个 Discord 机器人,并使用 CodeLyon 的Permissions V2视频作为参考。错误出现在我的 message.js 文件中,其中包含以下内容:require('dotenv').config();//create cooldowns mapconst cooldowns = new Map();module.exports = (Discord, client, m
2021-02-23
当我从 API 获取数据时,会发生此错误。TypeError: Cannot read property 'length' of undefined以下代码代表我的项目的主页。我想在主页上显示 20 个数组项。App.jsimport React, { useState, useEffect } from "react"import banner from "./assets/marvel-gro
2021-02-09
大家好,StackOverflow 的各位。我正在学习 three.js,作为一个学习项目,我选择制作一个类似于这个的 80 年代风格复古山丘。一切都进展顺利,但后来script.js:37 Uncaught TypeError: Cannot read property 'length' of undefinedat init (script.js:37)at script.js:6出现了。我到
2021-02-02
我今天遇到了一个非常奇怪的问题,需要在这里寻求帮助。因此,我有以下函数,并带有一些调试打印输出:function allLongestStrings(inputArray) {console.log(inputArray);inputArray.sort((a,b)=> {return b.length-a.length;});console.log(inputArray);console.log
2021-02-01
我正在使用 TMDB API,它允许我在列表中显示电影。我有 Add.js 组件,它允许我进行查询和搜索电影并将它们添加到我的列表中但是我收到此错误:TypeError: Cannot read property 'length' of undefinedAdd.jsimport React, { useState } from "react";import { ResultCard } from
2021-01-15
我正在使用自定义过滤器来创建排序顺序,但从最不重要的开始,然后是下一个,但出现错误“ERROR TypeError:无法读取未定义的属性‘filter’”。请帮我修复,因为它不允许在页面上呈现任何内容。我需要做哪些更改来解决这个问题?任何帮助都值得赞赏。table-filter.pipe.tsimport { Pipe, PipeTransform } from "@angular/core";@
2021-01-14
这真的很奇怪。 我还有其他选择的框以相同的方式定义,但据说这是不确定的。这是html:426988101我可以在此时的下拉列表中看到一个选项。这是javascript,它是附加另一个选项:< /p>171220838刚刚将其正确显示在列表中的选择元素的值。 我可以在下拉列表中看到两个项目:“我的第一个监视列表”和“我的portfolio”(来自后端呼叫)。,但控制台。读取未定义的属性“长度”当附加
2021-01-10
我尝试渲染SectionList,但它返回了三个错误:Uncaught TypeError: Cannot read property 'length' of undefinedThe above error occurred in the <VirtualizedSectionList> component:Uncaught TypeError: Cannot read property 'le
2021-01-09
当访问 commerce js 中 cart 对象的 line_items 数组时,出现错误,提示未定义,但我仍然可以在控制台中看到它。以下是一些截图:错误:TypeError: Cannot read property 'length' of undefinedCartD:/Zayeed/Projects/e_commerce/src/components/Cart/Cart.jsx:74 |5
2020-12-23
我是初学者。我正在做 Coding Addict 的这个练习。练习:function longestWords(str){let words = str.split(" ");let size = 0;let max = [''];for(let i=0; i<words.length; i++){if(words[i].length >= size){size = words[i].length
2020-12-16