需要在调用的时候传入:
o._hover(1);var o = {
    id : 1,
    _hover: function(id) {
        var self = this,
            _config = self.config,
            _cache = self.cache;        this.id=id;
        alert(id);
        //鼠标悬停
        $(_config.list + ' li').hover(function(){
            //    /*    1    * /
            alert(id);
        });
    }
}
o._hover(1);

解决方案 »

  1.   

    我也这样写了,
    代码多贴点:
     Microblog.prototype = {
    _hover: function(id) {
    var self = this,
    _config = self.config,
    _cache = self.cache;
    this.id=id;
    //鼠标悬停
    $(_config.list + ' li').hover(function(){
                    alert(id);
                   }
    }调用的时候:
     function sayClick(id){
             Microblog.prototype._hover(id);
        };我这个可以传到_hover()里,但是传不到里边那个函数里
      

  2.   

    prototype是原型,调用的时候需要初始化。这是由js的语言规则决定的。
    demo here<!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8"/>
        <title>test</title>
        <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.10.2/jquery-1.10.2.min.js"></script>
    </head>
    <body>
    <input id="btn" type="submit" value="test" onclick="sayClick(this.id)" />
    <script type="text/javascript">
        function Microblog(){ }
        Microblog.prototype = {
            _hover: function(id) {
                var self = this,
                        _config = self.config,
                        _cache = self.cache;
                this.id=id;
                alert(id);
                //鼠标悬停
                $(_config.list + ' li').hover(function(){
                    alert(id);
                });
            }
        }
        function sayClick(id){
            var m = new Microblog();
            m._hover(id);
        };
    </script>
    </body>
    </html>
      

  3.   

    加一個字就好_hover: function(id) {
        var self = this,
            _config = self.config,
            _cache = self.cache;
        this.id=id;
        //鼠标悬停
        $(_config.list + ' li').hover(function(){
            /*    1    * /
            alert(self.id);
        });
    }
      

  4.   

    我也这样写了,
    代码多贴点:
     Microblog.prototype = {
    _hover: function(id) {
    var self = this,
    _config = self.config,
    _cache = self.cache;
    this.id=id;
    //鼠标悬停
    $(_config.list + ' li').hover(function(){
                    alert(id);
                   }
    }调用的时候:
     function sayClick(id){
             Microblog.prototype._hover(id);
        };我这个可以传到_hover()里,但是传不到里边那个函数里

    确实按你的方法改好了,多谢指教。