错误类型错误:无论我尝试什么,都无法读取未定义的属性“路径”

吞噬

无论我尝试什么,我都会收到未定义的错误。我有值的时候我console.log(this.EmployeeDetails.gallery);gallery[i].path确实有一个值,但我的浏览器控制台保持促使它,我尝试了不同的方法,如先设置为空字符串,另一个函数中移动的循环,并将其设置等待,一切都不起作用。

await this.employeeService.getEmployeeDetails(this.Employeeuuid).subscribe((res) => {
  this.EmployeeDetails = res as Employee[];
  this.data.serviceprice = this.EmployeeDetails.serviceprice;
  this.setEmployees();
  console.log(this.EmployeeDetails.gallery);

  for (let i = 0; i <= this.EmployeeDetails.gallery.length; i++) {
    this.photossrc = this.EmployeeDetails.gallery[i].path;
    const src = this.photossrc;
    const caption = 'Image ' + i + ' caption here';
    const thumb = this.EmployeeDetails.gallery[i].path;
    const album = {
      src: src,
      caption: caption,
      thumb: thumb
    };
    this.albums.push(album);
  }
});

错误类型错误:无法读取 EmployeeEditComponent.push../src/app/pages/employee/employee-edit/employee-edit.component.ts.EmployeeEditComponent.loadPhotosAndVideos(employee-edit.component.ts: 201) 在 SafeSubscriber._next (employee-edit.component.ts:96) 在 SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196) 在 SafeSubscriber.push ../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber. js:77) 在 Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/ map.js.MapSubscriber._next (map.js:41) 在 MapSubscriber.push。./node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter .js:38) 在 FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)

加里B

循环不应该小于或等于长度只是更小,像这样:

 for (let i = 0; i < this.EmployeeDetails.gallery.length; i++) {
     ...
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

角度:错误类型错误:无法读取未定义的属性___

错误类型错误:无法读取未定义的属性“标题”

错误类型错误:无法读取未定义的属性“...”

错误类型错误:无法读取未定义的属性“填充”

为什么我收到错误“未捕获的类型错误:无法读取 HTMLLIElement 处未定义的属性‘样式’。”?

错误类型错误:无法读取未定义的属性“stateName”

错误类型错误:无法读取未定义的属性

错误类型错误:无法读取未定义的属性“getUsers”

“类型错误:无法读取未定义的属性‘名称’”错误

我收到以下错误:错误类型错误:无法读取未定义的属性“无效”

类型错误:无法读取未定义的属性“类型”

错误类型错误:无法读取未定义的属性“列表”

错误类型错误:无法读取未定义的属性“_id”

渲染错误:“类型错误:无法读取未定义的属性‘’”

反应错误:类型错误:无法读取未定义的属性“路径名”

类型错误:无法读取未定义错误的属性“_id”

错误类型错误:无法读取未定义的属性“doc”

为什么我收到错误:类型错误:无法读取未定义的“拆分”的属性

**错误** 类型错误:无法读取未定义的属性“替换”

类型错误:每次我重新加载网页时都无法读取未定义的属性“1”

为什么我会收到“类型错误:无法读取未定义的属性‘发送’”?

类型错误:当我尝试使用 items.map 时无法读取未定义的属性“地图”

类型错误:无法读取未定义的属性(读取“图像”)

类型错误:无法读取未定义的属性(读取“缓存”)

类型错误:无法读取未定义的属性(读取“暗”)

类型错误:无法读取未定义的属性(读取“reduce”)

类型错误:无法读取未定义的属性(读取“类型”)

类型错误:无法读取未定义读取“2”的属性

未捕获的类型错误:无法使用 BrowserRouter 读取未定义的属性(读取“路径名”)