更新时间:2023-11-30 22:37:52
你确定 FirstName 和 LastName 是可观察对象?如果你不确定,试试这个:
You sure FirstName and LastName are observables? If you're not sure, try this:
optionsText: function(item) { return ko.unwrap(item.FirstName) + '-' + ko.unwrap(item.LastName); }
或者更好的是,在您的视图模型中创建一个计算:
Or better yet, create a computed in your viewmodel:
self.FullName = function() {
return ko.unwrap(self.FirstName) + '-' + ko.unwrap(self.LastName);
};
还有:
optionsText: 'FullName'