12345678910111213141516171819202122232425 |
- class Fn {
- constructor(id, name) {
- this.id = id
- this.name = name
- }
- say(talk) {
- console.log(`${this.name}:${talk}`);
- this.onSay({ date: new Date(), talk })
- }
- onSay() {}
- }
- let f = new Fn(1, '张三')
- f.onSay = function(e) {
- console.log(e)
- }
- f.say('你好')
|