我正在尝试访问 Reply.vue 文件中的命名 laravel 路由。我想做的就是将此路由作为属性传递给我的 reply 组件。但是在编译时出现以下错误:
invalid expression: Unexpected token : in
http://tddforum.com/thread/reply/10
Raw expression: :route="http://tddforum.com/thread/reply/10"
正如您所看到的,路线的值已正确分配给 :route 属性,但由于上述错误,页面无法加载。这是我的回复组件的第一行:
<reply :attributes="{{ $reply}}" :route="{{ route('reply.update',$reply->id) }}" inline-template>
这里出了什么问题?
谢谢, 是的
最佳答案
您正在使用 v-bind
它将值计算为 JavaScript,但您实际上传递的是字符串文字,因此只需删除 v-bind
(冒号) :
<reply :attributes="{{ $reply}}" route="{{ route('reply.update',$reply->id) }}" inline-template>
如果 reply
也是一个字符串,那么您也需要对其执行相同的操作。
关于javascript - 在 vue 组件属性中访问 laravel 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47734860/