开发者问题收集
我正在学习 React JS 教程,并尝试将 props 从一个组件传递到另一个组件,以便呈现曲目列表。我查看了一些有类似问题的线程,但没有任何建议可以解决我的问题,我不知所措。我怀疑这个问题与我的初始状态设置方式有关。我尝试了以下操作。无法读取未定义 REACT 的属性“map”按照上述建议,在接收组件时将“this.props”更改为“this.state”,反之亦然,但这并不能解决问题,只会
我正在按照在线教程学习有关 React.js 的受控输入,但不断收到错误TypeError: Cannot read property 'map' of undefinedimport CallRow from "./CallRow";import React from "react";class SearchPage extends React.Component {constructor()
我之前也做过类似的事情(在网格中显示项目),所以我尝试遵循该模式。我盯着这个看了一段时间,想找出问题所在。是不是有什么我没看到?帮助错误消息 9 | console.log(localStorage.getItem("shoppingCart")),10 | <div>11 | <Grid container spacing={3}>> 12 | {items.map((item)
我正在尝试使用commerce.js库创建一个电子商务网站。库 API 中已经有 8 种产品。我有一个Products.js组件,我将从App.js获得的产品对象数组传递给Product.js组件。为此,我使用映射函数将每个对象作为 props 传递给Product.js组件。但我收到了此错误。我尝试注释掉映射块,并且只有控制台记录了来自App.js的products变量和Products.js中
我遇到了错误TypeError: 无法读取未定义的属性(读取“地图”)此代码应返回卡片标题中的城市名称,该名称已在我的其他文件中定义,但引发了错误。代码:import React, {Component} from 'react';import Body from './Body';class Weather extends Component {constructor(props) {super
下面是我的控制器代码://///////Diary Notes Controller///////diary.controller('NotesController', ['$scope','$http', 'notesService', function ($scope, $http, notesService){////Get the Notes data back from the Serv
我的 app.component.ts 文件中定义了一个函数,其定义如下export class AppComponent {....onRowSelected(record:any) {this.selectedRecord = record;}....}当选择表行时,我将 app.component.html 文件中的函数用作回调函数<tr *ngFor="let record of reco
import { Injectable } from '@angular/core';export class Test {public id: number; public name: string; public fid: number};export const TESTS: Test[] = [{id: 1, name: 'Cat', fid: 1},{id: 2, name: 'Dog'
我正在尝试使用 angular 创建一个触发器,但是当我从我的 api 获取响应时,它返回undefined。这是我的global-search.ts文件:export class GlobalSearchComponent{searchable: String = '';professionals: any = {};constructor(public client: Http){}getPr
这是我当前的代码。在这种情况下,我该如何返回 rowData 值?private createRowData() {const rowData: any[] = [];this.http.get(`/assets/json/payment.json`).toPromise().then(response => response.json()).then(data => {data.items.ma
我在下面的类中有一个方法:export class SearchService {userUID: string;searchItems: any;private searchesCollection: AngularFirestoreCollection;constructor(private db: AngularFirestore,private afAuth: AngularFireAut
我有一个“user”类型的对象,它应该有一个函数“getPermission()”。在运行时(Angular 7)它会抛出错误“TypeError: this.user.getPermission 不是函数”。以下是我认为必不可少的内容:我的用户类:export class User {...public getPermission(): boolean {return true;}...}我有
作为初学者,我在使用 Angular 和 Observables 时遇到了一个问题。我有一个 API 可以获取数据库中某个特定餐厅的信息,但我必须通过 POST 请求来获取它。当餐厅登录时,我成功地从 auth.service 和另一个 API 获取了restaurantID,但是当我尝试在控制台中登录餐厅时,我得到了undefined。我一律没有权限在这里显示 API。代码:restaurant
我试图获取 ngOnInit 中的第二个函数返回值,但它给出未定义。如果我打印 SvgImage,它就会打印。我不知道我在哪里犯了错误。ngOnInit() {this.userService.displayEvents(this.user_id).subscribe(data => {this.eventArray = [];if (data.status == 'success') {data
我遇到一个问题,即某个函数返回了错误的返回值,而不是正确的返回值。模型:export module AbsModule {export class AbsModul{abs: string;state: boolean;}}import { Injectable } from '@angular/core';import { HttpClient, HttpHeaders } from '@an