目录两次赋值页面获取不到第一种方法第二种方法Vue赋值不成功问题两次赋值页面获取不到 vue两次赋值console.log出来的值为第二次赋的值尔页面显示的是第一次赋的值 getf
vue两次赋值console.log出来的值为第二次赋的值尔页面显示的是第一次赋的值
getfORM(){ //api3
var _this=this
var formSchemad=_this.formSchema
console.log(_this.formSchema)
axiOS({
method:'get',
url:'odoo/mobile/api3/JSONui?id=xxxx'
}).then(function(resp){
formSchemad=jsON.parse(resp.data);
console.log(formSchemad)
_this.formSchema=formSchemad; //第一次赋值
axios({
method:'get',
url:'odoo/mobile/api3/jsonui?id=xxxx_100'
}).then(function(respd){
_this.cdis=false
var mont=JSON.parse(respd.data);
var montname=[]
var montvalue=[]
console.log(mont)
for(var i=0;i<mont.length;i++){
montname.push(mont[i].name);
montvalue.push(mont[i].value);
formSchemad.properties[mont[i].name].value=mont[i].value;
}
console.log(formSchemad)
_this.formSchema=formSchemad; //第二次赋值
将两次赋值改为一次
将赋值的代码改为
_this.formSchema= json.parse(json.stringify(formSchemad));
data(){
applyFormMetaData:{
"name":"jack",
"discounted_profit":0,
}
}
var discounted_profit = 300;
// 普通赋值
this.applyFormMetaData.discounted_profit = discounted_profit;
// vue提供的方法重新显示声明
this.$set(this.applyFormMetaData, 'discounted_profit', discounted_profit);
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: vue两次赋值页面获取不到的解决
本文链接: https://www.lsjlt.com/news/146993.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0