如何在刀片视图中呈现xml svg响应

"I call an api that return a qrcode in xml svg format. I want to display that qrcode in blade view. I am stack with displaying the xml svg response in blade view."

I get an xml svg qrcode in controller from an API that I call, I want to display it in blade

In controller, this is how I render data to blade

return response()
    ->view(
        'qrcode',
        [
            'output' => $output
        ],
        200
    )
    ->header('Content-Type', 'image/svg+xml');

This is how my blade look like:

<svg {{$output}}></svg>

I expect to see variable an svg xml qrcode ($output variable contain it)on blade view

Place the output between the svg tags

<svg>{{ $output }}</svg>

You need to create a Response and attach the header to that, not the View.

$response = Response::make(View::make('qrcode', ['output' => $output]), 200);
$response->header('Content-Type', 'image/svg+xml');
return $response;

I'd also suggest just adding the header in your view, also:

<?php header('Content-Type: image/svg+xml'); ?>

{{ $output }} <!-- Try without SVG tags seems as you have XML tags in your $output anyway -->

For more info, refer to Laravel Docs