小编Mat*_*ttO的帖子

为什么我的球(物体)不会缩小/消失?

http://jsfiddle.net/goldrunt/jGL84/42/ 这是来自这个JS小提琴的第84行.通过取消注释线141-146,可以对球施加3种不同的效果.'反弹'效果可以正常工作,但'asplode'效果无效.我应该在asplode函数中包含'shrink'函数吗?

// balls shrink and disappear if they touch
var shrink = function(p) {
    for (var i = 0; i < 100; i++) {
        p.radius -= 1;
    }
    function asplode(p) {
        setInterval(shrink(p),100);
        balls.splice(p, 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript html5

208
推荐指数
2
解决办法
9001
查看次数

在Flask中使用Jinja2获取嵌套的dict项

这个Flask控制器的字典

projects = {
        'life-calc':{'url':'life-calc',
                    'title': 'Life Calculator'},
        'text-game':{'url':'text-game',
                    'title':'Text Adventure'},
        'fill-it-up':{'url':'fill-it-up',
                    'title':'Fill It Up'},
        'rock-paper-scissors':{'url':'rock-paper-scissors',
                    'title':'Rock, Paper, Scissors'},
        'bubble-popper':{'url':'bubble-popper',
                    'title':'Bubble Popper'}
            }


@app.route('/')
def index():
    return render_template("index.html",
                            projects = projects)
Run Code Online (Sandbox Code Playgroud)

和模板本身

    <h1>
        List of My Projects
    </h1>

    <ol>
        <li>
            <a href = "life-calc">Life Calculator</a>
        </li>
        <li>
            <a href = "text-game">Adventure Game</a>
        </li>
        <li>
            <a href = "fill-it-up">Fill It Up</a>
        </li>
        <li>
            <a href = "rock-paper-scissors">Rock Paper Scissors</a>
        </li>
        <li>
            <a href = "bubble-popper">Bubble Popper</a>
        </li>
    </ol>
    <p>test section below</p> …
Run Code Online (Sandbox Code Playgroud)

python dictionary jinja2 flask

13
推荐指数
2
解决办法
3万
查看次数

类方法的Ruby"Undefined Method"

Ruby初学者努力将这个@@ people hash的值打印到控制台

class Person
  #have a first_name and last_name attribute with public accessors
  attr_accessor :first_name 
  attr_accessor :last_name

  #have a class attribute called `people` that holds an array of objects
  @@people = []

  #have an `initialize` method to initialize each instance
  def initialize( first_name, last_name )#should take 2 parameters for first_name and last_name
    #assign those parameters to instance variables
    @first_name = first_name
    @last_name = last_name
    #add the created instance (self) to people class variable
    @@people.push self
  end

  #have a `search` …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

dictionary ×1

flask ×1

html5 ×1

javascript ×1

jinja2 ×1

python ×1

ruby ×1

ruby-on-rails ×1