js的类调用

类对象:ClassB

let ClassB = {         ClassName:'ClassB',     GetName()     {         alert(1);         } }  export default ClassB;

 

调用:ClassA

import ClassB from './ClassB.js'  ClassB.GetName();      //document.getElementById('root').value = ClassB.ClassName;

 

页面:Html

<!DOCTYPE html> <html> <head> <meta charset=UTF-8> <title>Insert title here</title> <script src=https://unpkg.com/babel-standalone@6/babel.min.js></script>  </head> <body> <input id='root' />  <script src=js/ClassB.js type=module></script> <script src=js/ClassA.js type=module></script> </body> </html>