Tôi đã sau đối tượng Knockout.js:Knockout.js - làm thế nào để tôi nhận được giá trị của một thuộc tính quan sát được bên trong một quan sát được tính toán?
var viewModel = {
description : ko.observable(""),
Name : ko.observable(""),
productid : ko.observable(""),
productmodel : ko.observable(""),
productnumber : ko.observable(""),
text_relevance : ko.observable(""),
mydunamicfield : ko.computed(function() {
return "bq=(and " +
((this.description == "") ? "" : ("description:" + this.description + " ")) +
")";
} , this)
};
Nhưng mydunamicfield
tài sản không sản xuất các kết quả nối chính xác. Nếu tôi cố gắng tham khảo this.description()
bên trong chức năng khác, tôi thấy các thông báo lỗi sau khi trang được tải:
Property 'description' of object [object Window] is not a function
vấn đề trong trường hợp này là gì?