函数'start'将用户名和密码传递给函数logIn。问题是我得到:
'ReferenceError:找不到变量:用户名'
问题出现在代码段的末尾。在片段的第二个和第三个“@echo”中,变量“用户名”正确显示。
问题是:如何将参数用户名和密码进一步传递给嵌套函数?
片段:
logIn = (username, password) ->
@echo '--- LogIn ---'
@echo '--- KNOWN HERE = ' + username + " ---"
@then ->
@echo '--- username KNOWN HERE = ' + username + ' ---'
@evaluate ->
@echo '--- @evaluate username NOT KNOWN HERE = ' + username + ' ---'
完整代码:
casper = require('casper').create({
clientScripts: ["includes/jquery.min.js"],
verbose: true,
logLevel: 'debug'
})
logIn = (username, password) ->
@echo '--- LogIn ---'
@echo '--- '+username+' // '+password+" ---"
@then ->
@echo '--- username in do = ' + username + ' ---'
@evaluate ->
@echo '--- @evaluate username = ' + username + ' ---'
$('#id_email').val(username)
$('#id_password').val(password)
$('.AuthForm').submit()
start = ->
@start loginURL
@echo '--- accounts.length = ' + accounts.length + ' ---'
logIn.call @, accounts[currentAccount][0], accounts[currentAccount][1]