呈现错误:“ TypeError:无法读取null的属性'PAY_TYPE'

时间:2020-05-12 15:49:39

标签: javascript vue.js

我想通过使用JSON.parse()将字符串转换为对象来显示 callback_details 中的 PAY_TYPE ,但是我尝试并始终将错误作为问题标题。 / p>

我的代码:

/etc/odoo/odoo.conf

data():

<td class="text-xs-left">{{props.item.payment_method}}<br>({{JSON.parse(props.item.callback_details).PAY_TYPE}})</td>

},

我要显示的是 callback_details 中的 PAY_TYPE

data(){
return{
  loading: false,
  startDate: '',
  endDate: '',
  startMenu: false,
  endMenu: false,
  pagination:{
    rowsPerPage: -1
  },
  orders:[],
  payment:[],
  list1: [],
  list2: [],
  payment_headers:[
    { text: this.$translate('merchant'),     value: 'merchant' },
    { text: this.$translate('shop_owner'),    value: 'shop_owner', sortable: false },
    { text: this.$translate('platform_fee'),      value: 'platformFee', sortable: false },
    { text: this.$translate('total_earning'),      value: '', sortable: false }
  ],
  details_headers:[
    { text: this.$translate('shop_name'),    value: 'shop_name' },
    { text: this.$translate('date'),    value: 'created' },
    { text: this.$translate('buyer_yippi'),    value: 'yippiWallet' },
    { text: this.$translate('purchase'),       value: 'yippsAmount', sortable: false },
    { text: this.$translate('payment_type'),    value: 'payment_method', sortable: false},
    { text: this.$translate('platform_fee'),      value: 'platformFee', sortable: false },
    { text: this.$translate('earning_fee'),      value: '', sortable: false }
  ],
  json:{},
  count: 0,
  tableSettingsOne: {
            descending: true,
            sortBy: null,
            rowsPerPage: 25,
            pageSizes: [
                {"text":"5","value":5},
                {"text":"10","value":10},
                {"text":"25","value":25},
                {"text":"50","value":50},
                {"text":"All","value":-1}
            ]
    },
    tableSettingsTwo: {
            descending: true,
            sortBy: null,
            rowsPerPage: 25,
            pageSizes: [
                {"text":"5","value":5},
                {"text":"10","value":10},
                {"text":"25","value":25},
                {"text":"50","value":50},
                {"text":"All","value":-1}
            ]
    }
}

而且我遇到了这些错误:

callback_details: "{"TXN_ID":"262439","PAY_TYPE":"VISAMASTER","STATUS_INFO":"2003267b9029b3b"}

任何人都知道要解决此问题吗?谢谢。

2 个答案:

答案 0 :(得分:0)

您在callback_details上加上了引号:

callback_details: {"TXN_ID":"262439","PAY_TYPE":"VISAMASTER","STATUS_INFO":"2003267b9029b3b"}

答案 1 :(得分:0)

尝试一下。

  callback_details: JSON.parse('{"TXN_ID":"262439","PAY_TYPE":"VISAMASTER","STATUS_INFO":"2003267b9029b3b"}'); 

还有

<td class="text-xs-left">{{props.item.payment_method}}<br>({{props.item.callback_details.PAY_TYPE}})</td>