只是示例,示例#1有效,但是可以将“参数”传递给对象值内的函数,如示例#2中所示吗? 示例#2不起作用,我需要什么?
示例1
var CANINE = {
DOG: function(){
CANINE.DOG_RACE(prompt("Dog name:"));
},
DOG_RACE: function(name) {
alert("Retriever's name:" + name);
}
}
示例2
var CANINE = {
DOG: function(){
CANINE.DOG_RACE.retriever(prompt("Dog name:"));
},
DOG_RACE: function(){
function retriever(name){
alert("Retriever's name:" + name);
}
}
}
通话功能
onClick="CANINE.DOG()"
答案 0 :(得分:2)
你的第二个例子应该是这样的:
var CANINE = {
DOG: function(){
CANINE.DOG_RACE.retriever(prompt("Dog name:"));
},
DOG_RACE: {
retriever: function(name){
alert("Retriever's name:" + name);
}
}
}