【发布时间】:2017-06-21 01:17:56
【问题描述】:
对于新手问题,我很抱歉,我正在使用KnockoutJS,我正在尝试从一个可观察对象中获取 base64String 值并将其存储在另一个可观察对象中,然后再将其发送出去。
为什么我需要这样做? 好吧,由于某种原因,当 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 is not a function
标签: c# asp.net-mvc knockout.js