首页 > 解决方案 > 在与项目相关的投票投票期间,我在用 vscode 编写时收到输入太少的参数错误

问题描述

代码如下:

import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Component, Input, OnInit } from '@angular/core'; 
import ApexCharts from "apexcharts";

@Component({
  selector: 'app-poll-vote',
   templateUrl: './poll-vote.component.html',
   styleUrls: ['./poll-vote.component.scss']
})

export class PollVoteComponent implements OnInit {
  @Input() voted: boolean;
  @Input() options: string[];
  @Input() results: number[];
  @Input() question: string;
  voteForm: FormGroup;

  constructor(private fb: FormBuilder) {
     this.voteForm = this.fb.group({
      selected : this.fb.control("",[Validators.required]),
   })
  }

 ngOnInit(): void {
    if(this.voted){
    this.generateChart()
    }
 }

 submitForm(){
    console.log(this.voteForm.value);
 }

 generateChart(){
    const options: ApexCharts.ApexOptions = {
      series : [
        {
          data : this.results,
        },
      ],
      chart : {
        height : 350,
        type : 'bar',
      },
      plotOptions :{
        bar : {
          columnWidth :'45%',
          distributed : true,
       },
      },
      legend:{
        show: false,
      },
      xaxis :{
        categories : this.options,
      },
    };
    const chart = new ApexCharts(document.getElementById('poll-results'),options);
    chart.render()
  }
}

输出错误如下图: [1]: https://i.stack.imgur.com/btuTP.png

有谁知道如何解决这个问题?

标签: angularjstypescripterror-handlingcompiler-errorsangularjs-directive

解决方案


推荐阅读