具有类型脚本和vue的highcharts,键入不兼容的错误

问题描述 投票:0回答:1

当使用带有类型脚本和vue的高图时,如下所示的错误,似乎类型不兼容,我该如何避免这些错误?:

“类型的参数'{chart:{type:string;}; title:{text:string; align:string; verticalAlign:string; style:{...'不能分配给'Options'类型的参数。属性'series'是不兼容的。输入'{dataLabels:{enabled:boolean;}; name:string; innerSize:string; data:number []; states:{h ...'不能赋值给''(SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | ...'。

import Highcharts from 'highcharts';
import HighChartsMore from 'highcharts/highcharts-more.js';
updateHealthChart(){
    var options = {
      chart: {
            type: 'pie'
        },
        title: {
            text: '75%',
            align: 'center',
            verticalAlign: 'middle',
            style:{"color": '#00c73c'},
            y: -5, 
        },

        colors: [
            '#00c73c',
            '#f2f2f2'
        ],
        series: [{
            dataLabels: {
                enabled: false,
            },
            name: 'Jane',
            innerSize: '90%',
            // sliced: true,
            data: [9,3],

            states:{
                hover:{
                    enabled: false,
                }
            }
        }]

    };

  Highcharts.chart('health', options);
  }
typescript vue.js highcharts
1个回答
0
投票

问题解决如下:

 import Highcharts, {Options} from 'highcharts';
    Highcharts.chart('health', options as Options);
© www.soinside.com 2019 - 2024. All rights reserved.