溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

vue兩次賦值頁面獲取不到怎么解決

發(fā)布時(shí)間:2022-04-24 10:41:39 來源:億速云 閱讀:225 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹“vue兩次賦值頁面獲取不到怎么解決”的相關(guān)知識,小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“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);

    關(guān)于“vue兩次賦值頁面獲取不到怎么解決”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點(diǎn)。

    向AI問一下細(xì)節(jié)

    免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

    vue
    AI