0

레일즈 5.1.4를 아래 코드와 함께 사용하고 있습니다. material.js 파일이 처리되고 material-components-web 모듈이 다운로드되고 발견되었음을 확인했습니다.window.autoInit in material-components-web 및 webpacker를 사용하는 레일

window.mdc.autoInit()으로 전화 할 때 mdc이 정의되지 않은 이유는 무엇입니까?

// app/javascript/packs/material.js 
import 'material-components-web' 

// app/views/layouts/application.html.eeb 
<html> 
    <head> 
    <%= javascript_pack_tag 'material' %> 
    </head> 
    <body> 
    <script>window.mdc.autoInit();</script> 
    </body> 
</html> 

I 별도로 @material/auto-init을 가져

  • 을 시도했습니다.
  • 팩 파일 내에 console.dir(window)/console.dir(this)을 추가합니다. this는 팩 파일 내부 window 아니고 수출은 레일과 material-components-web 작품은 내가

    // app/javascript/packs/material.js 
    import * as mdc from 'material-components-web' 
    // for accessing it as a window object 
    window.mdc = mdc 
    

    않았다하려면 this

답변

0

에 부착되지 않는 그리고 내가 window.mdc.autoInit() 확인이에 불렀다했다 본문의 끝