在 angular 8 中使用 ngx-highlightJs 未显示数字列

Mon*_*rma 5 angular8

给定的数据是一些主要的 HTML 页面和模块的提供者

<pre>
    <code [highlight]="previewText" [lineNumbers]="true"></code>
</pre>

providers: [
    {
      provide: HIGHLIGHT_OPTIONS,
      useValue: <HighlightOptions>{
        lineNumbers: true
      }
    }
  ]
Run Code Online (Sandbox Code Playgroud)

Sus*_*hil 0

在 app.module.ts 文件中

import { HighlightModule, HIGHLIGHT_OPTIONS, HighlightOptions } from 'ngx-highlightjs';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
     HighlightModule 
  ],
  providers: [
    {
      provide: HIGHLIGHT_OPTIONS,
      useValue: <HighlightOptions>{
        lineNumbers: true
      }
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

应用程序组件.ts

import { Component } from '@angular/core';
import { HighlightResult } from 'ngx-highlightjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
 // response: HighlightResult;

  code = `const index=0` 
}
Run Code Online (Sandbox Code Playgroud)

应用程序组件.html

<pre><code [highlight]="code" [lineNumbers]="true" ></code></pre>
Run Code Online (Sandbox Code Playgroud)