【发布时间】:2019-03-10 21:03:53
【问题描述】:
我在 Laravel 中的 url 有问题
<td> Website: <a href="{{url($data[0]->internet)}}" target="_blank">{{$data[0]->internet}}</a></td>
其中internet 是一些网站名称,例如www.foo.com
问题是输出 URL 是 http://localhost/www.foo.com 而不是 http://www.foo.com
【问题讨论】:
-
target="_blank" ?
-
我可以从 laravel 文档中看到:
The url helper may be used to generate arbitrary URLs for your application. The generated URL will automatically use the scheme (HTTP or HTTPS) and host from the current request:,那你为什么要使用 url() ? -
“在特定公司的新标签中”是什么意思? “试过但没用”是什么意思?设置
target="_blank"是首选方法。如果这对您来说“不起作用”,您可能有一个设置/插件阻止打开新选项卡,或者您正在更改错误的代码。Inspect element在浏览器的开发者工具中,并确保target="_blank"在那里。 -
Ooohhook,所以您的问题是公司的 URL 不正确?在新标签页中打开按预期工作?如果是这样,您可能想重新表述您的问题。并使用
$data[0]->internet而不是url($data[0]->internet)。感谢@D.Dimitrov -
抱歉,问题没有正确提出。target="blank" 工作正常,但打开的 URL 不正确。没有 url 助手,它给我的输出为 localhost/foo/bar/www.foo.com