我在尝试使用扩展器时遇到了一些问题(我认为)。由于我只显示日期并且不允许编辑它们,我更喜欢只使用这样的绑定处理程序:
Shipped on <span data-bind="date: shipDt"></span>
这是处理程序:
    ko.bindingHandlers.date =
    {
        update: function (element, valueAccessor: () => any, allBindingsAccessor: any)
        {
            return ko.bindingHandlers.text.update(element, function ()
            {
                var value: any = ko.utils.unwrapObservable(valueAccessor());
                if (value == null)
                {
                    return null;
                }
                if (typeof value === "string")
                {
                    value = new Date(value);
                }
                return value.toShortDateString();
            }, allBindingsAccessor, null, null);
        }
    };
我选择像这样向 Date 对象添加一个原型(并调用toShortDateString在处理程序中创建的 Date 对象)-但是您可以将上面的逻辑替换为Globalize您喜欢的任何内容。
Date.prototype.toShortDateString = function ()
{
    return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear();
};