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項目如何從session中獲取對象,并且使用里面的屬性
這篇文章主要介紹了vue項目如何從session中獲取對象,并且使用里面的屬性問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-12-12
詳解Vue-cli中的靜態(tài)資源管理(src/assets和static/的區(qū)別)
這篇文章主要介紹了Vue-cli中的靜態(tài)資源管理(src/assets和static/的區(qū)別,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-06-06
Vue3+Vite項目中引入pinia和pinia-plugin-persistedstate的方法代碼
這篇文章主要給大家介紹了關于Vue3+Vite項目中引入pinia和pinia-plugin-persistedstate的相關資料,Pinia是Vue.js的官方狀態(tài)管理庫,輕量且功能強大,支持模塊化和TypeScript,PiniaPluginPersistedState是一個插件,需要的朋友可以參考下2024-11-11
Vue3實現(xiàn)provide/inject的示例詳解
Vue3 的 Provide / Inject 的實現(xiàn)原理其實就是巧妙利用了原型和原型鏈來實現(xiàn)的。本文將通過示例為大家介紹下provide/inject的具體實現(xiàn),需要的可以參考一下2022-11-11

