2. Let $P$ be any point on the graph of the function $f(x)=x+\frac{2}{x}(x>0)$, and draw perpendiculars from point $P$ to the $x$-axis and $y$-axis, with the feet of the perpendiculars being $A$ and $B$ respectively. Then the minimum value of $|P A|+|P B|$ is $\qquad$
2. 4 .

Let $P(x, y)$. According to the problem,
$$
|P A|=|y|=y,|P B|=|x|=x,
$$

where, $y=x+\frac{2}{x}(x>0)$.
$$
\begin{array}{l}
\text { Hence }|P A|+|P B|=y+x=2\left(x+\frac{1}{x}\right) \\
\geqslant 2 \times 2 \sqrt{x \cdot \frac{1}{x}}=4,
\end{array}
$$

The equality holds if and only if $x=\frac{1}{x}$.
Since $x>0$, thus, when $x=1$, the above inequality takes the equality.

Therefore, when and only when $x=1$, $|P A|+|P B|$ has the minimum value 4.