0
早上好!Emberjs - 发送PUT请求时,模型不会改变布尔值
在模型上发送更改的boolean值时,我们遇到请求问题。
从服务器加载模型时,模型中的值为false,但在将布尔值更新为true值时,请求不会发送true,而会发送false。
路由器:
actions: {
save:function() {
let post = this.controller.get("model");
console.log(post.get("isPost")); // logs **true**
post.save().then(() => { // request {"description":"The Post","isPost":**false**}
this.transitionTo('posts');
}).catch((error) => {
console.log(error);
});
}
}
型号:
import Model from './default';
import DS from 'ember-data';
export default Model.extend({
description: DS.attr('string'),
isPost: DS.attr('boolean')
});
我tryed设定布尔为true直接在模型上,但它发送同样的错误请求,发送虚假的,而不是真的...
airline.set('isPost',true); airline.save ....
;'而不是' DS.Model'? – ddoria921
你的后端作为对你的保存的回应返回什么? – acorncom