vue兩次賦值頁面獲取不到的解決
更新時間:2022年04月23日 10:37:09 作者:問馫
這篇文章主要介紹了vue兩次賦值頁面獲取不到的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
兩次賦值頁面獲取不到
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));?
vue賦值不成功問題
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);以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Vue中 key keep-alive的實現(xiàn)原理
這篇文章主要介紹了Vue中 key keep-alive的實現(xiàn)原理,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-09
vue.js element-ui tree樹形控件改iview的方法
這篇文章主要介紹了vue.js element-ui tree樹形控件改iview的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03
Vue解決element-ui消息提示$message重疊問題
這篇文章主要為大家介紹了Vue解決element-ui消息提示$message重疊問題,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-08-08

