tab1.page.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Component } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. @Component({
  4. selector: 'app-tab1',
  5. templateUrl: 'tab1.page.html',
  6. styleUrls: ['tab1.page.scss']
  7. })
  8. export class Tab1Page {
  9. searchQuery: string='';
  10.   searchResults: string[] = ['探索星球', '探索轨迹', '探索资源', '探索敌人信息'];
  11.   filteredResults: string[] = [];
  12.   showResults: boolean = false;
  13. constructor(private router: Router) {}
  14. goTocommunity()
  15. {
  16. this.router.navigate(['/community'])
  17. }
  18. goToNewPage()
  19. {
  20.   this.router.navigate(['/login']);
  21. }
  22. search() {
  23.     this.filteredResults = this.searchResults.filter(result =>
  24.       result.toLowerCase().includes(this.searchQuery.toLowerCase())
  25.     );
  26.     if (this.searchQuery && this.searchQuery.trim() !== '' && this.filteredResults.length > 0) {
  27.       this.showResults = true;
  28.     } else {
  29.       this.showResults = false;
  30.     }
  31.   }
  32. reports: Report[] = [
  33. { id: 1, title: '报告标题1', content: '这是报告内容1' },
  34. { id: 2, title: '报告标题2', content: '这是报告内容2' },
  35. { id: 3, title: '报告标题3', content: '这是报告内容3' },
  36. ];
  37. }
  38. export interface Report {
  39. id: number;
  40. title: string;
  41. content: string;
  42. }