嗨,在我的应用程序中,当我单击 addfields 时,会出现一个表单,当我尝试提交时,我收到错误字符串不是函数。这是我的添加功能代码
self.addTierFields = function (tier) {
self.Tiers.push(new Tier({
bothrate: self.bothrate(),
compoundratee: self.compoundratee(),
simplerate: self.simplerate(),
rate: self.rate()
}));
self.show(true);
};
这是 js fiddle 链接 demo
最佳答案
self.bothrate
等在代码中访问时并不是 knockout 可观察量。
您已在 html 中定义了它们,它们只是常规字符串。
所以试试这个:
self.addTierFields = function (tier) {
self.Tiers.push(new Tier({
bothrate: self.bothrate,
compoundratee: self.compoundratee,
simplerate: self.simplerate,
rate: self.rate
}));
self.show(true);
};
关于javascript - knockout js 错误 String 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25663603/