Javascript变量未定义错误
Javascript variable not defined error
我有以下代码:
// Get combination prices
var combID = $('#idCombination').val();
var combinationsFromController;
var combination = combinationsFromController[combID];
if (typeof combination === 'undefined')
return;
// Set product (not the combination) base price
var basePriceWithoutTax = +productPriceTaxExcluded;
var basePriceWithTax = +productPriceTaxIncluded;
var priceWithGroupReductionWithoutTax = 0;
当我执行它时,Chrome总是抱怨:
combinationsFromController is not defined.
有人能帮我为什么会发生这种事吗?
我试过了:
var combinationsFromController = new Array();
var combination = combinationsFromController[combID];
运气不佳。
您从未从控制器中定义组合。
var combinationsFromController;
// combinationsFromController is undefined because you did not give it a value
在使用变量之前,必须给它们一个值。
你可能想要
var combinationsFromController = getCombitationsFromController()
将getCombitationsFromController()
替换为代码以从控制器获取组合。
相关文章:
- webRTC错误未定义配置
- gmaps4rails 2.4.6未捕获引用错误:未定义Gmaps
- 未捕获引用错误:未定义validateform
- 为什么我会出现此错误"未捕获引用错误:未定义标题;
- Sitecore”;未捕获引用错误:未定义MultilistWithSearch;
- Wordpress:未捕获引用错误:未定义速度
- Node.js引用错误:未定义类名
- Replace()产生“;未捕获的类型错误:未定义的不是函数“;当与零一起使用时
- 错误-未定义easeInBounce
- 未捕获的引用错误:未定义<映射键>
- 未捕获的类型错误:未定义不是上的函数.GetElementByID
- Javascript错误:未捕获引用错误:未定义编辑
- javascript onchange取消绑定错误|未定义
- requirejs优化器错误:未定义窗口
- 未捕获引用错误:未定义PrintThisPage
- JSHint 错误:未定义我的应用程序 (W117)
- 当我编写脚本时,它显示引用错误:未定义宽度
- socket.io - 引用错误:未定义 io
- 反应.js:未捕获类型错误:未定义不是一个函数
- 出现“未捕获的类型错误:未定义不是函数”控制台错误