如何调用带有点的函数?例如:lib.execute();
或hello.greet();
当然不行:
function hello.world() {
document.write('Hello world');
}
<button onclick="hello.world();">Click me</button>
我在某个地方看到它使用了变量,但我不记得如何使用它
在您的示例中,正确的做法是:
let go = {
abc: function() {
document.write('Hello world!');
}
}
你需要创建一个类,或者一个充当类的对象,然后你可以在它上面创建属性作为函数。