-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
42 lines (39 loc) · 1.08 KB
/
index.html
File metadata and controls
42 lines (39 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
let obj = {}
let name = 'jianwei'
obj.age = 29
let Body = document.getElementsByTagName('body')[0]
let Phtml = document.createElement('p')
Phtml.innerHTML = name
Body.appendChild(Phtml)
Object.defineProperty(obj, 'name', {
// value: '男',
configurable: true, // 可配置对象,删除属性
// writable: false, // 可修改对象, 可写 (不允许同一个属性存在两个及以上的存取访问器配置,所以writable或者value不能与get/set同时配置,否则报错。)
enumerable: true, // 可枚举
get() {
return name
},
set(val) {
console.log(val)
name = val
}
})
// console.log(obj)
// for (let item in obj) {
// console.log(item)
// }
obj.name = 'xiaozhen'
console.log(name)
</script>
</body>
</html>