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>
标签:Insert,调用,GetName,ClassB,js,ClassName 来源: https://www.cnblogs.com/loge/p/16269017.html