首页 > 解决方案 > Vue.js。如何在 index.html 文件中获取当前 url?

问题描述

Vue.js。如何在 index.html 文件中获取当前 url?使用 index.html 中的纯 js,我只得到起始页的 url。要获取其他页面的 url,我必须刷新或保留初始页面的值。

<!-- index.php laravel blade -->

<div id="ui">
    <router-view></router-view>
</div>
<script>
    window.CanvasUI = @json($config);
</script>

<script type="text/javascript" src="{{ asset(mix('js/canvas-ui.js')) }}"></script>

标签: javascriptlaravelvue.jssingle-page-application

解决方案


使用纯 JS:

window.location.href

推荐阅读