【发布时间】:2022-01-23 05:20:21
【问题描述】:
我第一次在 Laravel 项目中使用 Alpine.js,想在组件中添加一个 href 标签,但是我不确定如何正确路由参数
<template x-for="(post, index) in posts" :key="index">
<a x-bind:href="post.id">
<p class="mt-2 block text-sm font-medium text-gray-900 truncate pointer-events-none">
<span x-text="post.text"></span>
</p>
</a>
</template>
重定向到
/id
并传递 id 但我需要转到指定的路线帖子并期待
/posts/id
如果我添加
<a x-bind:href="posts/post.id">
结果是重定向
/posts/NaN
【问题讨论】: