From 5e5dc0edcc808b2e2d7856bedfe82476c4d08609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=91?= <1665966989@qq.com> Date: Mon, 14 Nov 2022 05:57:33 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=9126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢金金 <1665966989@qq.com> --- ...\346\211\277\344\275\234\344\270\232.html" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "26\350\260\242\351\207\221\351\207\221/\344\275\234\344\270\232/11.7\347\273\247\346\211\277\344\275\234\344\270\232.html" diff --git "a/26\350\260\242\351\207\221\351\207\221/\344\275\234\344\270\232/11.7\347\273\247\346\211\277\344\275\234\344\270\232.html" "b/26\350\260\242\351\207\221\351\207\221/\344\275\234\344\270\232/11.7\347\273\247\346\211\277\344\275\234\344\270\232.html" new file mode 100644 index 0000000..213714f --- /dev/null +++ "b/26\350\260\242\351\207\221\351\207\221/\344\275\234\344\270\232/11.7\347\273\247\346\211\277\344\275\234\344\270\232.html" @@ -0,0 +1,25 @@ + + + + + + + Document + + + + + \ No newline at end of file -- Gitee From 6ff0c50bf08e480255798d50c006e9f22bf7acae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=91?= <1665966989@qq.com> Date: Mon, 14 Nov 2022 05:57:56 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=9126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢金金 <1665966989@qq.com> --- ...47\346\211\277\347\254\224\350\256\260.md" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "26\350\260\242\351\207\221\351\207\221/\347\254\224\350\256\260/11.7\347\273\247\346\211\277\347\254\224\350\256\260.md" diff --git "a/26\350\260\242\351\207\221\351\207\221/\347\254\224\350\256\260/11.7\347\273\247\346\211\277\347\254\224\350\256\260.md" "b/26\350\260\242\351\207\221\351\207\221/\347\254\224\350\256\260/11.7\347\273\247\346\211\277\347\254\224\350\256\260.md" new file mode 100644 index 0000000..63c424c --- /dev/null +++ "b/26\350\260\242\351\207\221\351\207\221/\347\254\224\350\256\260/11.7\347\273\247\346\211\277\347\254\224\350\256\260.md" @@ -0,0 +1,32 @@ +| ## 圣杯模式(全): | | | +| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| | [2](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_2) | | +| | [3](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_3) | ***\*优化:\**** | +| | [4](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_4) | | +| | [5](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_5) | - 我们可以将它封装为一个方法,因为每次继承都会创建一个新的Temp中间函数,造成了资源浪费。优化代码如下 | +| | [6](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_6) | | +| | [7](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_7) | ```javascript | +| | [8](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_8) | **var** inherit = (**function** () { | +| | [9](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_9) | **var** Temp = **function**() {} | +| | [10](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_10) | **return** **function** (Target, Origin) { //target继承自origin | +| | [11](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_11) | Temp.prototype = Origin.prototype | +| | [12](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_12) | Target.prototype = **new** Temp() | +| | [13](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_13) | Target.prototype.**constructor** = Target //为了让Target原型的constructor指回Target | +| | [14](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_14) | Target.prototype.uber = Origin.prototype //找到自己的超类 | +| | [15](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_15) | } | +| | [16](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_16) | })() | +| | [17](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_17) | ``` | +| | [18](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_18) | | +| | [19](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_19) | - 由于es6有了Object.create()方法,可以改变函数的隐式原型(_**proto**_),也可以不用中间函数 | +| | [20](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_20) | | +| | [21](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_21) | ```javascript | +| | [22](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_22) | **function** inherit(Target, Origin) { | +| | [23](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_23) | Target.prototype = Object.create(Origin.prototype) | +| | [24](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_24) | Target.prototype.**constructor** = Target | +| | [25](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_25) | Target.prototype.uber = Origin.prototype | +| | [26](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_26) | } | +| | [27](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_27) | ``` | +| | [28](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_28) | | +| | [29](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_29) | this | +| | [30](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_30) | | +| | [31](https://gitee.com/level-21-software-class-4/java-script/pulls/336/files#f7650314366b53c85cc442a4f967ebe5fa765b37_0_31) | 如果this有自己的属性,那么会覆盖掉原型上已有的属性。****(开发惯例:所有方法写到原型,部分属性写到this)一般来说属性是配置项,需要你主动传参去配置。但是一般来说某个插件的方法功能几乎是 | \ No newline at end of file -- Gitee