簡體   English   中英

通過不使用Viewmodel od剔除中的值來計算ko.compute

[英]ko.computed by not using values in Viewmodel od knockout

我們是否可以使用在viewmodel中無法觀察到的值進行ko.compute計算。

    self.EnableSave = ko.computed(function () {

        if ($('#PoolName').val().toString().trim().length > 0 && $('#Description').val().toString().trim().length > 0 && self.MatrixList().length > 0) {
            return true;
        }
        else {
            return false;
        }
    });

我看不出您無法在計算中使用不可觀察變量的任何原因。 但是,只有對可觀察對象的更改才會觸發計算對象觸發。 在這種情況下,僅當MatrixList更改時,才會重新計算計算值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM