“Vue Object.defineProperty”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
(建立内容为“https://www.bilibili.com/video/BV1Zy4y1K7SH?p=11”的新页面)
 
第1行: 第1行:
 
https://www.bilibili.com/video/BV1Zy4y1K7SH?p=11
 
https://www.bilibili.com/video/BV1Zy4y1K7SH?p=11
 +
 +
=== ES6 往对象上添加属性 ===
 +
<syntaxhighlight lang="html">
 +
<!DOCTYPE html>
 +
<html lang="en">
 +
<head>
 +
    <meta charset="UTF-8">
 +
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 +
    <title>回顾Object.defineProperty方法</title>
 +
</head>
 +
<body>
 +
    <script type="text/javascript">
 +
        let person = {
 +
            name:'张三',
 +
            sex:'男'
 +
        }
 +
        Object.defineProperty(person, 'age', {
 +
            value:18
 +
        })
 +
        console.log(person);
 +
    </script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>

2024年7月28日 (日) 09:51的版本

https://www.bilibili.com/video/BV1Zy4y1K7SH?p=11

ES6 往对象上添加属性

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>回顾Object.defineProperty方法</title>
</head>
<body>
    <script type="text/javascript">
        let person = {
            name:'张三',
            sex:'男'
        }
        Object.defineProperty(person, 'age', {
            value:18
        })
        console.log(person);
    </script>
</body>
</html>