如何在jquery中调用变量以放入{{ Storage::url()}}

n9vozmp4  于 2022-12-12  发布在  jQuery
关注(0)|答案(1)|浏览(81)

我有数据表在laravel 8和我是编码一个表得到一些属性,代码像这样Controller
我想调用r.file来获取访问文件路径的值,路径文件如下=“assets/file/Dr3cxy0QM2GDH1IpaWeiMZDUXfTVhl6QkazEyKYh.pdf”
Blade View
但结果是Browser
如何使href值像这样?
<a href="/storage/assets/file/Dr3cxy0QM2GDH1IpaWeiMZDUXfTVhl6QkazEyKYh.pdf">Test.pdf</a>

6jygbczu

6jygbczu1#

You can use the jQuery .data() method to store the data in an HTML element and then access the data using the .data() method in the jQuery selector.
For example, if you have an HTML element with a class of storage-url and you want to store a variable called "url" in it, you could do the following:

<div class="storage-url" data-url="{{storage::url(url)}}"></div>

Then, in your jQuery code, you can access the data using the .data() method:

var url = $('.storage-url').data('url');

相关问题