Grid-connected inverters (GCIs) have been widely used in modern power systems. When connecting the GCIs to weak grids, the stability of the GCIs will be affected by the coupling effect between the phase-locked loop (PLL) and the voltage feedforward. To guarantee the stability of the GCIs, this coupling effect should be analyzed, and the control parameters of the GCIs should be designed considering this coupling effect. In this paper, a stability-margin-oriented optimization method for designing the controller parameters of the GCIs to mitigate the coupling effect in weak power grids is proposed. Firstly, the proportional gain of the PLL is designed based on the Routh Criterion to obtain the required gain margins. Then, given the lack of phase margin is very serious in the system with multiple GCIs in parallel, the grid voltage feedforward coefficient (VFC) is designed for improving the phase margin based on the singular value of the system. Simulation and experimental results have been provided, which have verified the effectiveness of the design method proposed in this paper.