先化简, 再求值: $\left(\frac{x^{2}-x}{x^{2}-2 x+1}+\frac{2}{1-x}\right) \div \frac{x-2}{x^{2}-1}$, 其中 $x=3 \tan 30^{\circ}-\left(\frac{1}{3}\right)^{-1}+\sqrt{12}$.
解: $\left(\frac{x^{2}-x}{x^{2}-2 x+1}+\frac{2}{1-x}\right) \div \frac{x-2}{x^{2}-1}$

$$
\begin{gathered}
=\left[\frac{x(x-1)}{(x-1)^{2}}-\frac{2}{x-1}\right] \cdot \frac{(x+1)(x-1)}{x-2} \\
=\left(\frac{x}{x-1}-\frac{2}{x-1}\right) \cdot \frac{(x+1)(x-1)}{x-2} \\
=\frac{x-2}{x-1} \cdot \frac{(x+1)(x-1)}{x-2}
\end{gathered}
$$

$=x+1$

当 $x=3 \tan 30^{\circ}-\left(\frac{1}{3}\right)^{-1}+\sqrt{12}=3 \times \frac{\sqrt{3}}{3}-3+2 \sqrt{3}=\sqrt{3}-3+2 \sqrt{3}=3 \sqrt{3}-3$ 时, 原式 $=3 \sqrt{3}-3+$ $1=3 \sqrt{3}-2$