首页 > 其他 > 详细

YUI3 Y.Base.create

时间:2014-06-15 00:51:34      阅读:372      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
<script type="text/javascript">

    YUI.add(‘electron‘, function(Y) {

        var REST_ENERGY = 511.00;

        Y.Electron = Y.Base.create(‘electron‘, Y.Base, [], {

            initializer: function() {
                Y.log(‘init...‘);
            },
            getSpeed: function() {
                var e_ratio = REST_ENERGY / this.get(‘energy‘);
                return Math.sqrt(1 - e_ratio * e_ratio);
            }
        },ATTRS = {
            charge: {
                value: -1,
                readOnly: true
            },
            energy: {
                value: REST_ENERGY,
                validator: function(en) {
                    return (en >= REST_ENERGY);
                }
            }
        });

    }, ‘0.0.1‘, {requires: [‘base-build‘]});

    YUI().use(‘electron‘, function(Y) {

        var e1 = new Y.Electron();
        e1.set(‘energy‘, 8000);
        Y.log(e1.getSpeed());

    });
</script>
</body>
</html>

YUI3 Y.Base.create,布布扣,bubuko.com

YUI3 Y.Base.create

原文:http://www.cnblogs.com/weats/p/3786041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!