<input type="button" value=" 返 回 首 页 " onclick="window.open('route('index')','_self')" class="inputbutton">这里调用不了,应该怎么改写
答案
问题根源:JS 字符串里面不会解析 Blade 模板语法,你直接写 route('index') 原样当成字符串了。
正确写法
<input type="button" value=" 返 回 首 页 " onclick="window.open('{{ route('index') }}','_self');" class="inputbutton">核心:包上 {{ }} 让 Blade 先渲染出真实 URL。