[英]Using route into js foreach loop
I have this code我有这个代码
data.forEach(element => {
dataHtml += `<a href="{{ route('pl.frontend.article.single', ['id' => '']) }}/` +element.id+ `"><figurestyle="background-image: url(/uploads/article/` +element.cover+ `)"> </figure></a></li>`;
});
It doesn't work becouse Laravel display an error that this route required parameters它不起作用,因为 Laravel 显示此路由需要参数的错误
Missing required parameters
缺少必需的参数
Why it doesn't work?为什么它不起作用? How can I solve my problem?
我该如何解决我的问题?
I think if you'll modify code like following, it will work!我想如果你像下面这样修改代码,它会起作用的!
data.forEach(element => {
dataHtml += `<a href="{{ route('pl.frontend.article.single'," + `element.id` + "}}"><figurestyle="background-image: url(/uploads/article/` +element.cover+ `)"> </figure></a></li>`;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.