目录

safeMixin()

功能

将源对象的属性复制到目标对象。 目标对象中已经存在的属性不会被覆盖。

语法

langx.safeMixin(target,source,deep)

参数

范例

Example: 空对象 safeMixin 后,b 显示输出值。

<!DOCTYPE html>
<html>

<head>
    <style>

    </style>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
    <script>
    require.config({
        baseUrl: "./",
        packages: [{
            name: "skylark",
            location: "../../../src/skylark"
        }, ]
    });
    </script>
</head>

<body>
   person safeMixin obj . result  obj.name <b></b>
    <script>
    require(["skylark/finder", "skylark/langx", "skylark/datax"], function(finder, langx, datax) {
        var person = {
            name: 'John',
            age: 29
        };
        var obj = {};
        langx.safeMixin(obj, person);
        datax.text(finder.find("b"), obj.name);
    });
    </script>
</body>

</html>