在Vue.js中显示JSON数组

时间:2018-11-25 01:57:56

标签: json vue.js coldfusion format fw1

我正在从Coldfusion Framework / 1 API中以JSON格式获取此数据:

{
  "COLUMNS": [
    "PRODUCT_ID",
    "PRODUCT_NAME",
    "PRODUCT_STATUS",
    "DT_CREATED"
  ],
  "DATA": [
    [
      102,
      "Window",
      "In Production",
      "November, 02 2018 10:33:13"
    ],
    [
      105,
      "Window",
      "Delivered",
      "November, 11 2018 15:00:00"
    ],
    ETC...
  ]
}

在开发人员工具中,使用Vue工具,我得到了:

  • 数据
    • 错误:错误
    • 正在加载:true
    • windows:对象
      • 列:数组[4]
      • 数据:数组[22]

我正在使用axios

new Vue({
    el: '#windows-list-data',
    data() {
      return {
      windows: null,
      loading: true,
      errored: false
    }
 },
mounted() {
  axios
    .get('https://my-server.local/index.cfm?action=api.get')
    .then( response => {
      this.windows = response.data

     })
    .catch( error =>  {
      console.log(error) 
      this.errored = true
    })
    .finally( () => this.loading = false )
}

有人可以告诉我如何在视图中使用Vuejs渲染数据吗? 谢谢

1 个答案:

答案 0 :(得分:1)

似乎应该改变

this.windows = response.data

let respDataStr = response.data
let jsObject = JSON.parse(respDataStr)
this.windows = jsObject