{"id":131,"date":"2022-01-21T07:39:48","date_gmt":"2022-01-21T07:39:48","guid":{"rendered":"http:\/\/114.132.224.28\/?p=131"},"modified":"2022-01-21T07:39:48","modified_gmt":"2022-01-21T07:39:48","slug":"rollup-%e5%bc%95%e5%85%a5es%e5%92%8ccommonjs%e5%bc%95%e5%8f%91%e7%9a%84%e5%8f%98%e9%87%8f%e5%86%b2%e7%aa%81","status":"publish","type":"post","link":"http:\/\/localhost\/2022\/01\/21\/rollup-%e5%bc%95%e5%85%a5es%e5%92%8ccommonjs%e5%bc%95%e5%8f%91%e7%9a%84%e5%8f%98%e9%87%8f%e5%86%b2%e7%aa%81\/","title":{"rendered":"rollup \u5f15\u5165es\u548ccommonjs\u5f15\u53d1\u7684\u53d8\u91cf\u51b2\u7a81"},"content":{"rendered":"\n

\u7528rolluo\u6253\u5305vue3\u548cquill.js\uff0cvue3\u4f1a\u4ee5es\u7684\u6a21\u5f0f\u5f15\u5165\uff0cvue3\u7684\u4ee3\u7801\u4f1a\u653e\u5230bundle.js\u7684\u5168\u5c40\u4e2d\uff0cText\u4f1a\u76f4\u63a5\u6ce8\u5165\u8986\u5199\u4e86\u539f\u751f\u7684Text\u7684\u5b9a\u4e49\uff0c\u800cquill.js\u4ee5commonjs\u5bfc\u5165\uff0c\u4f1a\u521b\u4e00\u4e2aiife\u7684\u51fd\u6570\u4f5c\u7528\u57df\uff0c\u4f46\u662f\u5728\u8bbf\u95eeText\u65f6\u4f1a\u8bfb\u5230Vue\u4e2d\u8986\u5199\u7684Text\uff0c\u5bfc\u81f4quill\u5728\u5224\u65ad\u7684\u539f\u751f\u7684Text\u65f6\u5019\u629b\u9519\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n
\"\"<\/figure>\n\n\n\n

\u6b64\u65f6\u7684Text\u4f1a\u88ab\u8986\u5199\u4e3aSymbol.<\/p>\n\n\n\n

Ps:<\/p>\n\n\n\n

instaceof\u7528\u4e8e\u68c0\u6d4b\u5de6\u503c\u7684__proto__\u662f\u5426\u6307\u5411\u53f3\u503c\u7684prototype\uff0c\u53f3\u503c\u5982\u679c\u4e0d\u662fobject\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n

Symbol.hasInstance\u65b9\u6cd5\u53ef\u4ee5\u81ea\u5b9a\u4e49\u884c\u4e3a<\/p>\n\n\n\n

class MyArray {\n  static [Symbol.hasInstance](instance) {\n    return Array.isArray(instance);\n  }\n}\nconsole.log([] instanceof MyArray);<\/code><\/pre>\n\n\n\n

\u6253\u5f00\u591a\u4e2awindow\u6216iframe\u884c\u4e3a\u4f1a\u53d8\u5f97\u4e0d\u51c6\u786e\uff0c<\/p>\n\n\n\n

\u5efa\u8bae\u68c0\u67e5\u539f\u59cb\u7c7b\u578b\u8fd8\u662f\u7528Array.isArray(myObj)<\/code> \u6216\u8005Object.prototype.toString.call(myObj) === \"[object Array]\"<\/code> \u6765\u5b89\u5168\u7684\u68c0\u6d4b\u4f20\u8fc7\u6765\u7684\u5bf9\u8c61\u662f\u5426\u662f\u4e00\u4e2a\u6570\u7ec4<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7528rolluo\u6253\u5305vue3\u548cquill.js\uff0cvu …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost\/wp-json\/wp\/v2\/posts\/131"}],"collection":[{"href":"http:\/\/localhost\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"http:\/\/localhost\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"http:\/\/localhost\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}