2016-04-25 82 views
0

:咧嘴笑:任何人都可以幫我解決這個問題? 我有一個類MDL: MaterialDesignLiteUpgradeElements.ts「沒有導出成員」我的MTL模塊中出現錯誤

import {Directive, AfterViewInit} from 'angular2/core'; 
declare var componentHandler; 
@Directive({ 
    selector: '[mdl]' 
}) 
export class MDL implements AfterViewInit { 
    ngAfterViewInit() { 
     componentHandler.upgradeAllRegistered(); 
    } 
} 

並且在這之後的疊後:Material Design Lite tooltips not working with Angular 2 我加了這一點:

ngAfterViewInit() { 
    componentHandler.upgradeDom(); 
    } 

在使用類MTL 管理的看法,但它說:

MaterialDesignLiteUpgradeElements has no exported member "componentHandler" 

控制檯錯誤:

EXCEPTION: TypeError: Cannot read property 'upgradeDom' of undefined 

任何想法?

回答

2

我沒有進入Angular2,但是我在Material Design Lite(MDL)中遇到了與ReactJS相同的問題。

你得到EXCEPTION: TypeError: Cannot read property 'upgradeDom' of undefined錯誤的原因是MDL默認不導出任何模塊。您可以按照以下建議導出模塊。

  1. 要麼就得從material.js文件& import/require在組件文件手動導出componentHandler
  2. 或者,如果您使用的是像的WebPack任何捆綁,你可以利用出口裝載機&的再使用import/require出口componentHandler

我都給予了詳細的描述在這裏SO/Material Design Lite with ReactJS (import/require Issue)

希望它有幫助!

+0

它運作良好:)謝謝; p – Slater

+0

@Slater太棒了!歡迎! – krishnaxv

相關問題