text: (window.webpackJsonp=window.webpackJsonp||[]).push([[79],{169:function(t,r,e){"use strict";e.r(r);var a=e(0),s=Object(a.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,r=t.$createElement,e=t._self._c||r;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"底层原理"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#底层原理","aria-hidden":"true"}},[t._v("#")]),t._v(" 底层原理")]),t._v(" "),e("h3",{attrs:{id:"object-defineproperty"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#object-defineproperty","aria-hidden":"true"}},[t._v("#")]),t._v(" "),e("strong",[t._v("Object.defineProperty()")])]),t._v(" "),e("h4",{attrs:{id:"方法会直接在一个对象上定义一个新属性，或者修改一个对象的现有属性，-并返回这个对象。"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#方法会直接在一个对象上定义一个新属性，或者修改一个对象的现有属性，-并返回这个对象。","aria-hidden":"true"}},[t._v("#")]),t._v(" 方法会直接在一个对象上定义一个新属性，或者修改一个对象的现有属性， 并返回这个对象。")]),t._v(" "),e("h4",{attrs:{id:"一、语法"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#一、语法","aria-hidden":"true"}},[t._v("#")]),t._v(" 一、语法")]),t._v(" "),e("blockquote",[e("p",[e("strong",[t._v("Object.defineProperty(obj, prop, descriptor)")])])]),t._v(" "),e("h4",{attrs:{id:"二、参数"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#二、参数","aria-hidden":"true"}},[t._v("#")]),t._v(" 二、参数")]),t._v(" "),e("h4",{attrs:{id:"_1、obj"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_1、obj","aria-hidden":"true"}},[t._v("#")]),t._v(" "),e("strong",[t._v("1、obj")])]),t._v(" "),e("ul",[e("li",[t._v("要在其上定义的属性的对象")])]),t._v(" "),e("h4",{attrs:{id:"_2、prop"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_2、prop","aria-hidden":"true"}},[t._v("#")]),t._v(" "),e("strong",[t._v("2、prop")])]),t._v(" "),e("ul",[e("li",[t._v("要定义或修改的属性的名称")])]),t._v(" "),e("h4",{attrs:{id:"_3、descriptor"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_3、descriptor","aria-hidden":"true"}},[t._v("#")]),t._v(" "),e("strong",[t._v("3、descriptor")])]),t._v(" "),e("ul",[e("li",[t._v("将被定义或修改的属性描述符。")])]),t._v(" "),e("h4",{attrs:{id:"三、返回值"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#三、返回值","aria-hidden":"true"}},[t._v("#")]),t._v(" 三、返回值")]),t._v(" "),e("ul",[e("li",[t._v("被传递给函数的对象，即第一个参数obj")])]),t._v(" "),e("h4",{attrs:{id:"四、简述"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#四、简述","aria-hidden":"true"}},[t._v("#")]),t._v(" 四、简述")]),t._v(" "),e("ul",[e("li",[t._v("针对属性，我们可以使用这个Object.defineProperty()方法上的属性，来操作是否要修改数据，以及数据是否可以被"),e("em",[t._v("for...in")]),t._v("或*Object.keys()*遍历（枚举）")]),t._v(" "),e("li",[t._v("对象里目前存在的属性描述符有两种形式: "),e("strong",[t._v("数据描述符")]),t._v("和"),e("strong",[t._v("存取描述符")]),t._v("。"),e("strong",[t._v("数据描述符")]),t._v("是一个具有值得属性，该值有可能是可写的或不可写的。"),e("strong",[t._v("存取描述符")]),t._v("是由getter-setter函数对描述的属性。描述符必须是这两种形式之一，不能同时是两者")])])])}],!1,null,null,null);r.default=s.exports}}]);