【问题标题】:Angular 6 mathjax not workingAngular 6 mathjax 不工作
【发布时间】:2018-11-25 04:56:22
【问题描述】:

我有 Angular 6 的项目。我通过运行以下命令安装了 Mathjax

npm install mathjaxnpm install --save @types/mathjax

我已经创建了指令

    import { Directive, Input, OnChanges, ElementRef, OnInit } from '@angular/core';

    @Directive({
      selector: '[Mathjax]'
    })
    export class MathjaxDirective implements OnChanges {

      @Input('Mathjax') private value: string;

      constructor(private element: ElementRef) {
      }


      ngOnInit() {
        this.update();
      }

      ngOnChanges() {
        this.update();

      }

      update() {

        this.element.nativeElement.innerHTML = this.value;
        MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.element.nativeElement]);

      }

    }

我正在使用这个指令

<span [Mathjax]="mathjaxTest"></span>

它在控制台中没有显示错误并且它不工作。 打印的是 mathjax 字符串,而不是制作数学方程式

【问题讨论】:

    标签: angular mathjax


    【解决方案1】:

    您需要在指令中导入 MathJax。

    import * as Mathjax from 'mathjax';
    

    【讨论】:

    • 显示错误。 'g:/../mathjax-test/node_modules/@types/mathjax/index.d.ts' 不是模块。
    猜你喜欢
    • 2019-08-03
    • 2017-01-28
    • 2018-12-18
    • 2019-01-24
    • 2019-01-29
    • 2019-01-07
    • 1970-01-01
    • 2018-12-07
    • 2017-01-10
    相关资源
    最近更新 更多