对不起,新手问题,我正在与KnockoutJS
和我试图从一个observable获取base64String值并将其存储在另一个observable之前发送它。从KO.Observable获取对象
为什么我需要这样做? 嗯,出于某种原因,当base64String被传递时,它有多个图层被发送到NULL的对象。
任何帮助或建议,将不胜感激。
var CreateSalesVM = {
UserId: ko.observable(),
Name: ko.observable(),
Phone: ko.observable(),
Email: ko.observable(),
Item: ko.observable(),
Description: ko.observable()
这件作品是我有
IMAGETWO: ko.observable({
base64StringArray: ko.observableArray()
}),
IMAGE: ko.computed({
read: function() {
return IMAGETWO().base64StringArray();
},
deferEvaluation: true
}),
/************** \
btnCreateSales: function() {
// IMAGE = this.IMAGETWO().base64StringArray();
console.log("Image text ", this.IMAGE());
//console.log("Host usrl ", urlHostPath);
//console.log("Ko is ", ko.toJSON(this));
$.ajax({
url: urlPath,
type: 'post',
dataType: 'json',
data: ko.toJSON(this),
contentType: 'application/json',
success: function (result) {
//console.log("This was a success");
// window.location.href = urlPath + '/';
alert(ko.toJSON(this));
// console.log("Ko is ", ko.toJSON(this));
},
error: function (err) {
//console.log("Ko is ", ko.toJSON(this));
if (err.responseText == "success")
{
//console.log("This was an erro success", urlPath);
// window.location.href = urlPath + '';
}
else {
alert(err.responseText);
// console.log("This was an error ", urlHostPath);
}
},
complete: function() {
}
});
}
};
ko.applyBindings(CreateSalesVM);
你现有的代码有什么问题? –
对不起,发生错误 - CreateVM.js:26 Uncaught TypeError:IMAGETWO不是函数 – Dwill