@url做什么?

问题描述 投票:-1回答:1

我在ajax请求呼叫部分时遇到了这个@url

$.ajax({
       type: "POST",
       url: "{{ @url("/accounts/upload-sf/validate") }}",
       data: formData,
       cache: false,
       contentType: false,
       processData: false,
       success: function(response_json) { ...

@urlurl有什么不同?

php laravel url-routing
1个回答
1
投票

自定义Laravel指令。您可以创建要在刀片模板中使用的自定义函数。 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);
}

}

© www.soinside.com 2019 - 2024. All rights reserved.