{"id":451,"date":"2020-02-14T18:41:43","date_gmt":"2020-02-14T10:41:43","guid":{"rendered":"https:\/\/blog.cqdefxxx.com\/?p=451"},"modified":"2020-02-14T18:41:43","modified_gmt":"2020-02-14T10:41:43","slug":"%e5%af%b9%e8%b1%a1%e7%9a%84%e7%bb%a7%e6%89%bf%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/blog.viter.top\/index.php\/2020\/02\/14\/%e5%af%b9%e8%b1%a1%e7%9a%84%e7%bb%a7%e6%89%bf%e6%a8%a1%e5%bc%8f\/","title":{"rendered":"\u5bf9\u8c61\u7684\u7ee7\u627f\u6a21\u5f0f"},"content":{"rendered":"<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;title&gt;01_\u539f\u578b\u94fe\u7ee7\u627f&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;!--\n\u65b9\u5f0f1: \u539f\u578b\u94fe\u7ee7\u627f\n  1. \u5957\u8def\n    1. \u5b9a\u4e49\u7236\u7c7b\u578b\u6784\u9020\u51fd\u6570\n    2. \u7ed9\u7236\u7c7b\u578b\u7684\u539f\u578b\u6dfb\u52a0\u65b9\u6cd5\n    3. \u5b9a\u4e49\u5b50\u7c7b\u578b\u7684\u6784\u9020\u51fd\u6570\n    4. \u521b\u5efa\u7236\u7c7b\u578b\u7684\u5bf9\u8c61\u8d4b\u503c\u7ed9\u5b50\u7c7b\u578b\u7684\u539f\u578b\n    5. \u5c06\u5b50\u7c7b\u578b\u539f\u578b\u7684\u6784\u9020\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u5b50\u7c7b\u578b\n    6. \u7ed9\u5b50\u7c7b\u578b\u539f\u578b\u6dfb\u52a0\u65b9\u6cd5\n    7. \u521b\u5efa\u5b50\u7c7b\u578b\u7684\u5bf9\u8c61: \u53ef\u4ee5\u8c03\u7528\u7236\u7c7b\u578b\u7684\u65b9\u6cd5\n  2. \u5173\u952e\n    1. \u5b50\u7c7b\u578b\u7684\u539f\u578b\u4e3a\u7236\u7c7b\u578b\u7684\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\n--&gt;\n&lt;script type=\"text\/javascript\"&gt;\n  \/\/\u7236\u7c7b\u578b\n  function Supper() {\n    this.supProp = 'Supper property'\n  }\n  Supper.prototype.showSupperProp = function () {\n    console.log(this.supProp)\n  }\n\n  \/\/\u5b50\u7c7b\u578b\n  function Sub() {\n    this.subProp = 'Sub property'\n  }\n\n  \/\/ \u5b50\u7c7b\u578b\u7684\u539f\u578b\u4e3a\u7236\u7c7b\u578b\u7684\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\n  Sub.prototype = new Supper()\n  \/\/ \u8ba9\u5b50\u7c7b\u578b\u7684\u539f\u578b\u7684constructor\u6307\u5411\u5b50\u7c7b\u578b\n  Sub.prototype.constructor = Sub\n  Sub.prototype.showSubProp = function () {\n    console.log(this.subProp)\n  }\n\n  var sub = new Sub()\n  sub.showSupperProp()\n  \/\/ sub.toString()\n  sub.showSubProp()\n\n  console.log(sub)  \/\/ Sub\n\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;title&gt;02_\u501f\u7528\u6784\u9020\u51fd\u6570\u7ee7\u627f&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;!--\n\u65b9\u5f0f2: \u501f\u7528\u6784\u9020\u51fd\u6570\u7ee7\u627f(\u5047\u7684)\n1. \u5957\u8def:\n  1. \u5b9a\u4e49\u7236\u7c7b\u578b\u6784\u9020\u51fd\u6570\n  2. \u5b9a\u4e49\u5b50\u7c7b\u578b\u6784\u9020\u51fd\u6570\n  3. \u5728\u5b50\u7c7b\u578b\u6784\u9020\u51fd\u6570\u4e2d\u8c03\u7528\u7236\u7c7b\u578b\u6784\u9020\n2. \u5173\u952e:\n  1. \u5728\u5b50\u7c7b\u578b\u6784\u9020\u51fd\u6570\u4e2d\u901a\u7528call()\u8c03\u7528\u7236\u7c7b\u578b\u6784\u9020\u51fd\u6570\n--&gt;\n&lt;script type=\"text\/javascript\"&gt;\n  function Person(name, age) {\n    this.name = name\n    this.age = age\n  }\n  function Student(name, age, price) {\n    Person.call(this, name, age)  \/\/ \u76f8\u5f53\u4e8e: this.Person(name, age)\n    \/*this.name = name\n    this.age = age*\/\n    this.price = price\n  }\n\n  var s = new Student('Tom', 20, 14000)\n  console.log(s.name, s.age, s.price)\n\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;title&gt;03_\u7ec4\u5408\u7ee7\u627f&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;!--\n\u65b9\u5f0f3: \u539f\u578b\u94fe+\u501f\u7528\u6784\u9020\u51fd\u6570\u7684\u7ec4\u5408\u7ee7\u627f\n1. \u5229\u7528\u539f\u578b\u94fe\u5b9e\u73b0\u5bf9\u7236\u7c7b\u578b\u5bf9\u8c61\u7684\u65b9\u6cd5\u7ee7\u627f\n2. \u5229\u7528super()\u501f\u7528\u7236\u7c7b\u578b\u6784\u5efa\u51fd\u6570\u521d\u59cb\u5316\u76f8\u540c\u5c5e\u6027\n--&gt;\n&lt;script type=\"text\/javascript\"&gt;\n  function Person(name, age) {\n    this.name = name\n    this.age = age\n  }\n  Person.prototype.setName = function (name) {\n    this.name = name\n  }\n\n  function Student(name, age, price) {\n    Person.call(this, name, age)  \/\/ \u4e3a\u4e86\u5f97\u5230\u5c5e\u6027\n    this.price = price\n  }\n  Student.prototype = new Person() \/\/ \u4e3a\u4e86\u80fd\u770b\u5230\u7236\u7c7b\u578b\u7684\u65b9\u6cd5\n  Student.prototype.constructor = Student \/\/\u4fee\u6b63constructor\u5c5e\u6027\n  Student.prototype.setPrice = function (price) {\n    this.price = price\n  }\n\n  var s = new Student('Tom', 24, 15000)\n  s.setName('Bob')\n  s.setPrice(16000)\n  console.log(s.name, s.age, s.price)\n\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE html&gt; &lt;html lang=&#8221;en&#8221;&gt; &lt;head&gt; &lt;met","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[5],"_links":{"self":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/451"}],"collection":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/comments?post=451"}],"version-history":[{"count":0,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/451\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/media?parent=451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/categories?post=451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/tags?post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}