A method for reactive power compensation of power grid, comprising: detecting voltage of a power grid; when a voltage magnitude of the detected voltage is lower than a preset normal voltage magnitude, determining an electric reference parameter corresponding to the voltage; determining a current pulse width modulation mode according to the electric reference parameter corresponding to the voltage, wherein the PWM mode comprises: a unipolar modulation mode and a bipolar modulation mode; and outputting reactive power by using the current PWM mode, so as to implement reactive power compensation for the power grid; characterized in that the electric reference parameter corresponding to the voltage comprises: a voltage phase angle θ corresponding to the voltage; wherein the determining a current pulse width modulation mode according to the electric reference parameter specifically comprises: determining the unipolar modulation mode as the current PWM mode when the voltage phase angle θ corresponding to the voltage satisfies θ 1 ≤ θ ≤ θ 2, or θ 3 ≤ θ ≤ θ 4, in one current period; otherwise, determining the bipolar modulation mode as the current PWM mode, wherein θ 1 = arcsin U min U peak, U min is the minimum voltage magnitude required for implementing soft switching by using the unipolar modulation mode, U peak is the voltage peak value in the current period, and θ 2 = π -θ 1, θ 3 = π + θ 1, θ 4 =2 π - θ 1. detecting voltage of a power grid; when a voltage magnitude of the detected voltage is lower than a preset normal voltage magnitude, determining an electric reference parameter corresponding to the voltage; determining a current pulse width modulation mode according to the electric reference parameter corresponding to the voltage, wherein the PWM mode comprises: a unipolar modulation mode and a bipolar modulation mode; and outputting reactive power by using the current PWM mode, so as to implement reactive power compensation for the power grid; characterized in that the electric reference parameter corresponding to the voltage comprises: a voltage phase angle θ corresponding to the voltage; wherein the determining a current pulse width modulation mode according to the electric reference parameter specifically comprises: determining the unipolar modulation mode as the current PWM mode when the voltage phase angle θ corresponding to the voltage satisfies θ 1 ≤ θ ≤ θ 2, or θ 3 ≤ θ ≤ θ 4, in one current period; otherwise, determining the bipolar modulation mode as the current PWM mode, wherein θ 1 = arcsin U min U peak, U min is the minimum voltage magnitude required for implementing soft switching by using the unipolar modulation mode, U peak is the voltage peak value in the current period, and θ 2 = π -θ 1, θ 3 = π + θ 1, θ 4 =2 π - θ 1. determining the unipolar modulation mode as the current PWM mode when the voltage phase angle θ corresponding to the voltage satisfies θ 1 ≤ θ ≤ θ 2, or θ 3 ≤ θ ≤ θ 4, in one current period; otherwise, determining the bipolar modulation mode as the current PWM mode, wherein θ 1 = arcsin U min U peak, U min is the minimum voltage magnitude required for implementing soft switching by using the unipolar modulation mode, U peak is the voltage peak value in the current period, and θ 2 = π -θ 1, θ 3 = π + θ 1, θ 4 =2 π - θ 1.