Index.vue 715 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <script setup>
  2. import {watch,onMounted} from 'vue'
  3. import {apiChartInfoByCode} from '@/api/chart.js'
  4. import {chartRender} from './utils/render'
  5. const props=defineProps({
  6. code:{
  7. type:String,
  8. default:''
  9. },
  10. renderId:{//渲染到的dom id
  11. type:String,
  12. default:''
  13. }
  14. })
  15. onMounted(()=>{
  16. getChartInfo()
  17. })
  18. // 获取图表详情
  19. async function getChartInfo(){
  20. const res=await apiChartInfoByCode({UniqueCode:props.code})
  21. if(res.Ret===200){
  22. chartRender(res.Data,props.renderId)
  23. }
  24. }
  25. </script>
  26. <template>
  27. <div class="chart-box" :id="renderId"></div>
  28. </template>
  29. <style lang="scss" scoped>
  30. .chart-box{
  31. width: 100%;
  32. height: 100%;
  33. }
  34. </style>