12345678910111213141516171819202122232425 |
- /*
- * @Description: js类测试
- * @Autor: kindring
- * @Date: 2021-09-06 16:18:22
- * @LastEditors: kindring
- * @LastEditTime: 2021-09-06 17:40:17
- * @LastDescript:
- */
- 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('你好')
|