Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个属性 Name ,age observable。是否可以同时显示这两个属性并应用 css 相同?
是否可以同时使用姓名和年龄进行数据绑定?
谢谢你的帮助。
该data-bind属性可以指定如下表达式:
data-bind
data-bind="Name() + ' (' + Age() + ')'"
否则,您可以创建一个计算的 observable 来表示您的值,例如:
viewModel.nameWithAge = ko.computed(function() { return this.Name() + ' (' + this.Age() + ')'"; }, vieWModel);