相关疑难解决方法(0)

highlight.js不适用于Angular 2

我正在尝试使用highlight.js为我的应用程序添加语法高亮,但它似乎不适用于Angular 2.

你能不能让我知道我可能做错了什么?

这是Plnkr:https://plnkr.co/edit/G3NFFPGXKyc9mV1a6ufJ p = preview

这是组件

import {Component} from 'angular2/core';

@Component({
    selector: "my-app",
    template: `
      Hello!
      <pre>
        <code class="html">
          &lt;html&gt;
            &lt;body&gt;

            &lt;h1&gt;My First Heading&lt;/h1&gt;
            &lt;p&gt;My first paragraph.&lt;/p&gt;

            &lt;/body&gt;
          &lt;/html&gt;
        </code>
      </pre>
    `
})
export class AppComponent{
}
Run Code Online (Sandbox Code Playgroud)

这是我使用cdn添加highlight.js的地方:

<!DOCTYPE html>
<html>

<head>
  <!-- IE required polyfills, in this exact order -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.25/system-polyfills.js"></script>
  <script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>

  <!-- Angular polyfill required everywhere -->
  <script src="https://code.angularjs.org/2.0.0-beta.13/angular2-polyfills.js"></script>

  <script src="https://code.angularjs.org/tools/system.js"></script>
  <script src="https://code.angularjs.org/tools/typescript.js"></script>
  <script src="https://code.angularjs.org/2.0.0-beta.13/Rx.js"></script>
  <script src="https://code.angularjs.org/2.0.0-beta.13/angular2.dev.js"></script>
  <link rel="stylesheet" …
Run Code Online (Sandbox Code Playgroud)

syntax-highlighting highlight.js angular

8
推荐指数
2
解决办法
6304
查看次数