给定的数据是一些主要的 HTML 页面和模块的提供者
<pre>
<code [highlight]="previewText" [lineNumbers]="true"></code>
</pre>
providers: [
{
provide: HIGHLIGHT_OPTIONS,
useValue: <HighlightOptions>{
lineNumbers: true
}
}
]
Run Code Online (Sandbox Code Playgroud)
在 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)
| 归档时间: |
|
| 查看次数: |
330 次 |
| 最近记录: |