zoukankan      html  css  js  c++  java
  • 第八章 一个画线的封装事例

    先回答上一章的问题:

    两者的区别就是,一个是复制一份,一个是建立一个指向property.函数的一个指针

    下面我们看一个画线的事例.这里大家可以打开我的另一篇文章《js画线》。快捷通道

    整个函数的结构

     (function () {
            var h5 = function (d, c, r) {//参数为容器ID
                return new h5.divline(d, c, r);
            };
    
            h5.divline = function (d, c, r) {//参数为容器ID
                this.o;
                this.iso = false;
                this.lcolor = "#FF0000"; //默认颜色
                this.lr = 0
                if (d != null) {
                    if (isExist(d)) {
                        this.o = document.getElementById(d);
                        this.iso = true;
                        if (c != null) this.lcolor = c;
                        if (r != null) this.lr = r; ;
                    }
                }
            };
            h5.divline.prototype.line = function () {
                if (this.iso == true) {
                    var numargs = arguments.length;
                    if (numargs >= 2) {
                        for (var i = 0; i < numargs - 1; i++) {
                            //l(arguments[i], arguments[i + 1], this.lr, this.lcolor, this.o);//画线
                        }
    
                    }
                }
            }
            window.draw = h5;
        })();
    

    这里大家可以考虑下

    this.o;
    this.iso = false;
    this.lcolor = "#FF0000"; //默认颜色
    this.lr = 0;

    这几个变量是否可以这样定义:
    var o;
    var iso = false;
    var lcolor = "#FF0000"; //默认颜色
    var lr =0;

    到这里 本系列的文章暂时结束了,因为在写作的过程我发现巨大的差距,所以后续的两章,我需要一段时间的准备;
    这个系列的文章写完后,我准备发布自己的asp.net框架,仿照MVC,但是比MVC简单很多,适合做小型项目:-),到时候希望大家拍砖

    
    
  • 相关阅读:
    Lua build and install
    tomcat 配置的另外一种方法
    debian vsftp
    git(1)
    jd-gui安装
    debian crash log查看
    ros学习笔记
    51nod 1138 连续整数的和(数学公式)
    51nod 1428 活动安排问题(优先队列)
    Codeforces Round #347 (Div. 2) (练习)
  • 原文地址:https://www.cnblogs.com/blowfish/p/3247721.html
Copyright © 2011-2022 走看看