无法在Ionic2中使用Mathml

时间:2016-10-05 13:48:05

标签: ionic2 mathjax

我想在Ionic2中使用Mathml,我在index.html中添加了mathjax cdn,并在app.module.ts中添加了 CUSTOM_ELEMENTS_SCHEMA

<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_CHTML"></script>

@ggModule中的

我使用

import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { HelloIonicPage } from '../pages/hello-ionic/hello-ionic';
import { ItemDetailsPage } from '../pages/item-details/item-details';
import { ListPage } from '../pages/list/list';
import {MathmlComponent} from '../components/mathml-component/mathml-component';

@NgModule({
  declarations: [
    MyApp,
    HelloIonicPage,
    ItemDetailsPage,
    ListPage,
    MathmlComponent
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HelloIonicPage,
    ItemDetailsPage,
    ListPage
  ],
  providers: [],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

我的mathml-component.ts是

import {Component} from "@angular/core";

@Component({
  selector:'mathml-component',
  template:`
  <math>
    <mstyle displaystyle="true">
      <mover>
        <mrow>
          <mi>f</mi>
        </mrow>
        <mo>&#x2192;</mo>
      </mover>
    </mstyle>
  </math>
  `
})

export class MathmlComponent{


  constructor(){
    console.log('done')
  }
}

但我收到错误

polyfills.js:3 Unhandled Promise rejection: Template parse errors:
':math:mi' is not a known element:
1. If ':math:mi' is an Angular component, then verify that it is part of this module.
2. If ':math:mi' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
      <mover>
        <mrow>
          [ERROR ->]<mi>f</mi>
        </mrow>
        <mo>&#x2192;</mo>
"): MathmlComponent@5:10
':math:mrow' is not a known element:

Plz帮助。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。我没有使用MathMl,而是在MAthjax中使用Tex / Latex。