合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# this.$router.push replace go的用法 - this.$router.push 跳转到指定url路径,并想history栈中添加一个记录,点击后退会**返回到上一个页面** ``` <pre class="calibre13">``` <span class="token6">// 字符串</span> <span class="token2">this</span><span class="token1">.</span>$router<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token4">'index'</span><span class="token1">)</span> <span class="token6">// 对象</span> <span class="token2">this</span><span class="token1">.</span>$router<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token1">{</span>path<span class="token1">:</span> <span class="token4">'login-pw'</span><span class="token1">}</span><span class="token1">)</span> <span class="token6">// 带参数</span> <span class="token2">this</span><span class="token1">.</span>$router<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token1">{</span>path<span class="token1">:</span> <span class="token4">'login-pw'</span><span class="token1">,</span> query<span class="token1">:</span> <span class="token1">{</span><span class="token4">'account'</span><span class="token1">:</span> <span class="token2">this</span><span class="token1">.</span>account<span class="token1">.</span>account<span class="token1">}</span><span class="token1">}</span><span class="token1">)</span> <span class="token6">// 跳转后的页面获取参数</span> <span class="token2">this</span><span class="token1">.</span>account<span class="token1">.</span>account <span class="token">=</span> <span class="token2">this</span><span class="token1">.</span>$route<span class="token1">.</span>query<span class="token1">.</span>account ``` ``` this.$router.replace 跳转到指定url路径,但是history栈中不会有记录,点击返回会****跳转到上上个页面**** this.$router.go(n) **向前或者向后跳转n个页面**,n可为正整数或负整数