KnockoutJS 和 c# 视图
KnockoutJS and c# view
这可能是一个微不足道的问题,但我需要这方面的帮助。简而言之,这是我的视图模型文件的一部分,当项目在调试模式下编译时它工作正常:
var getValidDocs = function () {
if (exports.data.Language() == 'it-IT' && exports.data.TaxCode() != null) {
exports.validRegistrationFiles.removeAll();
ko.utils.arrayForEach(exports.allValidRegistrationFiles(), function (myRegistrationFile) {
var titolo = myRegistrationFile.Title._latestValue;
//Here the browser gives me an "Uncaught TypeError: Cannot read property 'includes' of undefined"
if (isIva.test(exports.data.TaxCode()) && titolo.includes('si_partita_iva')) {
exports.validRegistrationFiles.push(myRegistrationFile);
}
if (!isIva.test(exports.data.TaxCode()) && titolo.includes('no_partita_iva')) {
exports.validRegistrationFiles.push(myRegistrationFile);
}
})
console.log(exports.validRegistrationFiles());
}
};
但是当我在发布模式下编译时,我无法访问
myRegistrationFile.Title._latestValue
属性.
因此,我做不到
titolo.includes('si_partita_iva')
因为未定义。好吧,在这种情况下是否可以使用相当于 _latestValue 的 属性?
最后我就是这么做的
<!-- ko foreach: $root.validRegistrationFiles -->
<div class="row">
<!-- ko if: $root.checkIVA -->
<!-- ko if: Title().includes('si_partita_iva') -->
<div class="col-sm-12 icon">blah blah blah</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $root.checkCodFiscale -->
<!-- ko if: Title().includes('no_partita_iva') -->
<div class="col-sm-12 icon">blah blah blah</div>
<!-- /ko -->
<!-- /ko -->
</div>
<!-- /ko -->
因为其他一切都惨败
这可能是一个微不足道的问题,但我需要这方面的帮助。简而言之,这是我的视图模型文件的一部分,当项目在调试模式下编译时它工作正常:
var getValidDocs = function () {
if (exports.data.Language() == 'it-IT' && exports.data.TaxCode() != null) {
exports.validRegistrationFiles.removeAll();
ko.utils.arrayForEach(exports.allValidRegistrationFiles(), function (myRegistrationFile) {
var titolo = myRegistrationFile.Title._latestValue;
//Here the browser gives me an "Uncaught TypeError: Cannot read property 'includes' of undefined"
if (isIva.test(exports.data.TaxCode()) && titolo.includes('si_partita_iva')) {
exports.validRegistrationFiles.push(myRegistrationFile);
}
if (!isIva.test(exports.data.TaxCode()) && titolo.includes('no_partita_iva')) {
exports.validRegistrationFiles.push(myRegistrationFile);
}
})
console.log(exports.validRegistrationFiles());
}
};
但是当我在发布模式下编译时,我无法访问
myRegistrationFile.Title._latestValue
属性.
因此,我做不到
titolo.includes('si_partita_iva')
因为未定义。好吧,在这种情况下是否可以使用相当于 _latestValue 的 属性?
最后我就是这么做的
<!-- ko foreach: $root.validRegistrationFiles -->
<div class="row">
<!-- ko if: $root.checkIVA -->
<!-- ko if: Title().includes('si_partita_iva') -->
<div class="col-sm-12 icon">blah blah blah</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $root.checkCodFiscale -->
<!-- ko if: Title().includes('no_partita_iva') -->
<div class="col-sm-12 icon">blah blah blah</div>
<!-- /ko -->
<!-- /ko -->
</div>
<!-- /ko -->
因为其他一切都惨败