0
我想在两种情况下使用一种方法。一次有2个,一次有3个参数。当我用2个参数执行代码时,它给了我:Mobile app - undefined
,因为chosenProgram
参数是空的。当我想要在没有- undefined
的空参数输入的情况下如何修改语句?当一个为空时连接字符串不同
switchStatement: function(typeCode, chosenType, chosenProgram) {
switch (typeCode) {
case 1:
this.config.form__internet.find('input').val(chosenType + ' - ' + chosenProgram);
break;
case 2:
this.config.form__tv.find('input').val(chosenType + ' - ' + chosenProgram);
break;
}
}
添加'chosenProgram = chosenProgram || '''在方法开始时。 – Tushar
ES6:'function(typeCode,chosenType,chosenProgram =“”){' – Bergi