0
我想僅使用敲除來實現以下內容: - 我希望在單擊「button1」時使輸入字段爲空,並在「button2」被點擊。輸入字段是由它們各自的可觀察值綁定的數據。所以,我不確定我應該如何使觀察值爲null,然後在單擊button2時將其顯示回來。僅當使用敲除單擊按鈕時,輸入字段爲空
代碼:
var ViewModel = function() {
var self = this;
self.comment = ko.observable("hi there");
self.message = ko.observable("hello");
}
vm = new ViewModel();
ko.applyBindings(vm);
我的方法:
這裏有兩種方法我試過執行,但沒有在所有的工作:
myShow: function() {
comment = ko.observable("");
},
myHide: function() {
message = ko.observable("");
},
我會明白任何幫助。
謝謝。