How can I construct a continuous function $f$ satisfying that $f|_{\mathbb{Q}}$ is an injection and $f|_{\mathbb{R-Q}}$ is not an injection? How can I construct a continuous function $f:\mathbb{R}\rightarrow \mathbb{R}$ satisfying that $f|_{\mathbb{Q}}$ is an injection and $f|_{\mathbb{R-Q}}$ is not an injection? Can it be constructed?
I was troubled by the problem that if I add the condition $f(\mathbb{Q})\subset \mathbb{Q}$, whether the function can be constructed.
If I let $f(a)=f(b)$ where $a,b \in \mathbb{R-Q}$, and tried to construct a function satisfying that all the rational numbers in the neighborhoods of $a$ and $b$ have different function value. Then I don’t know how to  maintain the continuity of $f$.

For example
$$f(x)=\begin{cases}
\sqrt2\cdot x,\space x\geq 0\\
|x|, \space x<0\\
\end{cases}$$
is injective on $\mathbb Q$ but $f(-\sqrt 6)=\sqrt 6=\sqrt2\cdot\sqrt3=f(\sqrt 3)$.
$\textbf{Edit:}$ This is an answer to the original posed question without the requirement $f(\mathbb Q)\subseteq \mathbb Q$. 
