articlethree.component.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Component, OnInit } from '@angular/core';
  2. import * as Parse from "parse"
  3. @Component({
  4. selector: 'app-articlethree',
  5. templateUrl: './articlethree.component.html',
  6. styleUrls: ['./articlethree.component.scss']
  7. })
  8. export class ArticlethreeComponent implements OnInit{
  9. storiesData: any[] = []; // 给变量一个初始值
  10. titlesData: any[] = []; // 给变量一个初始值
  11. authorsData: any[] = []; // 给变量一个初始值
  12. datesData: any[] = []; // 给变量一个初始值
  13. constructor() { }
  14. ngOnInit(): void {
  15. const Jht430 = Parse.Object.extend('Jht430');
  16. const query = new Parse.Query(Jht430);
  17. query.get('jWdWQlpHsC').then((result) => {
  18. this.storiesData = result.get('stories');
  19. }).catch((error) => {
  20. console.error('Error retrieving stories data: ', error);
  21. });
  22. query.get('jWdWQlpHsC').then((result) => {
  23. this.titlesData = result.get('titles');
  24. }).catch((error) => {
  25. console.error('Error retrieving titles data: ', error);
  26. });
  27. query.get('jWdWQlpHsC').then((result) => {
  28. this.authorsData = result.get('authors');
  29. }).catch((error) => {
  30. console.error('Error retrieving authors data: ', error);
  31. });
  32. query.get('jWdWQlpHsC').then((result) => {
  33. this.datesData = result.get('dates');
  34. }).catch((error) => {
  35. console.error('Error retrieving dates data: ', error);
  36. });
  37. }
  38. comments = [
  39. { user: '阿平', avatar: '../../assets/images/passerby1.jpg', message: '哇塞' },
  40. { user: '明天在不在', avatar: '../../assets/images/passerby2.jpg', message: '啊啊啊啊啊啊啊啊啊啊啊' },
  41. { user: '无敌暴龙', avatar: '../../assets/images/passerby3.jpg', message: '在哪里?' }
  42. ];
  43. newComment: string = '';
  44. addComment() {
  45. if (this.newComment) {
  46. const newComment = {
  47. user: '我',
  48. avatar: '../../assets/images/slide1.jpg',
  49. message: this.newComment
  50. };
  51. this.comments.push(newComment);
  52. this.newComment = '';
  53. }
  54. }
  55. }