<template>
  <dv-scroll-board :config="boardConfig"></dv-scroll-board>
</template>
<script>
export default {
  data() {
    return {
      jsonData: null // 从后端获取的JSON数据
    }
  },
  computed: {
    boardConfig() {
      if (this.jsonData) {
        const data = JSON.parse(this.jsonData); // 将JSON字符串转换成对象
        const dataArray = Object.entries(data); // 将对象转换成二维数组
        const config = {
          data: dataArray
        };
        return config;
      }
      return null;
    }
  },
  mounted() {
    // 后端请求数据,并将返回结果赋值给jsonData
    // 示例代码中直接将jsonData赋值为JSON字符串
    this.jsonData = '{"A":10,"B":20,"C":30}';
  }
}
</script>

原文地址: https://www.cveoy.top/t/topic/qb7f 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录