答案1
\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}[auto]
\draw [dashed] (0,1) -- node[left] {Line} (3,5);
\draw [dashed] (1,1) -- node[above,sloped] {Line} (4,5);
\draw [dashed] (3,1) to ["Line"] (6,5); % use library quotes
\draw [dashed] (4,1) to ["Line",sloped] (7,5);% use library quotes
\end{tikzpicture}
\end{document}