:grinning: Anyone to help me with that ? I have a class MDL : MaterialDesignLiteUpgradeElements.ts
import {Directive, AfterViewInit} from 'angular2/core';
declare var componentHandler;
@Directive({
selector: '[mdl]'
})
export class MDL implements AfterViewInit {
ngAfterViewInit() {
componentHandler.upgradeAllRegistered();
}
}
And Following this stack post : Material Design Lite tooltips not working with Angular 2 I Added this :
ngAfterViewInit() {
componentHandler.upgradeDom();
}
In the class managing the view using MTL But it say :
MaterialDesignLiteUpgradeElements has no exported member "componentHandler"
The console error :
EXCEPTION: TypeError: Cannot read property 'upgradeDom' of undefined
Any ideas ?
答案 0 :(得分:2)
我没有进入Angular2但是,我在使用Material Design Lite(MDL)的ReactJS中遇到了同样的问题。
您收到EXCEPTION: TypeError: Cannot read property 'upgradeDom' of undefined
错误的原因是MDL默认情况下不会导出任何模块。您可以按照以下建议导出模块。
componentHandler
文件&手动导出material.js
。组件文件中的import/require
import/require
导出componentHandler
我在这里给出了详细说明SO/Material Design Lite with ReactJS (import/require Issue)
希望它有所帮助!