在vue项目中报错:
Property 'type' is missing in type '{ name: string; data: number[]; }' but required in type 'SeriesXrangeOptions'.
项目代码
<template lang="pug">
div(id="container",style="min-width:400px;height:400px")
</template>
<script lang="ts">
import * as Highcharts from "highcharts";
Highcharts.chart('container',{
chart: {
type: 'column'
},
title: {
text: '包含负值的柱形图'
},
xAxis: {
categories: ['苹果', '橘子', '梨', '葡萄', '香蕉']
},
series: [{
name: '小张',
data: [5, 3, 4, 7, 2]
}, {
name: '小彭',
data: [2, -2, -3, 2, 1]
}, {
name: '小潘',
data: [3, 4, 4, -2, 5]
}]
});
</script>
<style scoped lang="stylus"></style>
这个应该怎么改?什么情况下typescript写普通js代码会报错?
比如声明变量
let number=6;
而不是
let number:number=6;
这种形式下,也可以正常运行所以不知道在什么情况下会报错?
看起来,像是 series 里除了 name 跟 data ,还需要一个 type 。