js的类调用(Calling JS class)

类对象: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>
————————

Class object: ClassB

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

export default ClassB;

Call: classA

import ClassB from './ClassB.js'

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

Page: 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>