请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

1回答

接灰的电子产品 2024-07-02 20:03:06

你这几个 component 都声明为独立组件了吧?看报错是这样的,你看看 是不是设置了 “standalone: true”

@Component({
  standalone: true,
  })export class StandaloneComponent {
  // component logic}


0 回复 有任何疑惑可以回复我~
  • 提问者 昨夜星辰1024 #1
    我是设置了standalone为true,但是我改成false还是报错,TS-992010: 'imports' is only valid on a component that is standalone. [plugin angular-compiler]
    
        src/app/app.component.ts:8:11:
          8 │   imports: [RouterOutlet, SharedModule],
            ╵      
      Did you forget to add 'standalone: true' to this @Component?
    
        src/app/app.component.ts:12:13:
          12 │ export class AppComponent {
             ╵ 
    X [ERROR] TS-992010: 'imports' is only valid on a component that is standalone. [plugin angular-compiler]
    
        src/app/shared/components/horizontal-grid/horizontal-grid.component.ts:16:11:
          16 │   imports: [CommonModule, FormsModule],
             ╵            
      Did you forget to add 'standalone: true' to this @Component?
    
        src/app/shared/components/horizontal-grid/horizontal-grid.component.ts:20:13:
          20 │ export class HorizontalGridComponent implements OnInit {
             ╵           
    X [ERROR] TS-992010: 'imports' is only valid on a component that is standalone. [plugin angular-compiler]
    
        src/app/shared/components/image-slider/image-slider.component.ts:24:11:
         我是用的angular18版本,所以跟angular8有些区别,目前卡在这个位置怎么办呢?
    回复 有任何疑惑可以回复我~ 2024-07-03 17:47:53
  • 提问者 昨夜星辰1024 #2
    回复 昨夜星辰1024:import {
      Component,
    } from '@angular/core';
    import { CommonModule } from '@angular/common';
    
    export interface ImageSlider {
      imgUrl: string;
      link: string;
      caption: string;
    }
    
    @Component({
      selector: 'app-image-slider',
      standalone: false,
      imports: [CommonModule],
      templateUrl: './image-slider.component.html',
      styleUrl: './image-slider.component.scss'
    })
    
    export class ImageSliderComponent {
    
    }
    回复 有任何疑惑可以回复我~ 2024-07-03 17:58:09
  • 使用 Angular 14 ,需要和课程版本一致,具体课程版本的升级我有时间会做的
    回复 有任何疑惑可以回复我~ 2024-07-04 09:57:02
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信