@url 是做什么的?
what does @url do?
我在 ajax 请求调用部分中遇到了这个 @url
。
$.ajax({
type: "POST",
url: "{{ @url("/accounts/upload-sf/validate") }}",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(response_json) { ...
@url
与 url
有什么不同吗?
自定义 Laravel 指令。您可以创建自定义函数以在 blade 模板中使用。 https://laravel.com/docs/5.8/blade#extending-blade
查看方法签名:
if (! function_exists('url')) {
/**
* Generate a url for the application.
*
* @param string $path
* @param mixed $parameters
* @param bool $secure
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
*/
function url($path = null, $parameters = [], $secure = null)
{
if (is_null($path)) {
return app(UrlGenerator::class);
}
return app(UrlGenerator::class)->to($path, $parameters, $secure);
}
}
我在 ajax 请求调用部分中遇到了这个 @url
。
$.ajax({
type: "POST",
url: "{{ @url("/accounts/upload-sf/validate") }}",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(response_json) { ...
@url
与 url
有什么不同吗?
自定义 Laravel 指令。您可以创建自定义函数以在 blade 模板中使用。 https://laravel.com/docs/5.8/blade#extending-blade
查看方法签名:
if (! function_exists('url')) {
/**
* Generate a url for the application.
*
* @param string $path
* @param mixed $parameters
* @param bool $secure
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
*/
function url($path = null, $parameters = [], $secure = null)
{
if (is_null($path)) {
return app(UrlGenerator::class);
}
return app(UrlGenerator::class)->to($path, $parameters, $secure);
}
}