Php 在刀片模板中如何在双花括号内插入变量

Php 在刀片模板中如何在双花括号内插入变量,php,laravel,laravel-blade,Php,Laravel,Laravel Blade,我是拉雷维尔的新手,我不知道怎么做 我想插入这个@{{comment.user.avatar} 在这个 我得到的是这个 <img src="http://localhost:89/images/profile/{comment.user.avatar}"> 我想要的是 <img src="http://localhost:89/images/profile/avatarpicture.jpg"> 这是我的完整代码 <div class="card" v-

我是拉雷维尔的新手,我不知道怎么做

我想插入这个@{{comment.user.avatar}

在这个

我得到的是这个

<img src="http://localhost:89/images/profile/{comment.user.avatar}">

我想要的是

<img src="http://localhost:89/images/profile/avatarpicture.jpg">

这是我的完整代码

<div class="card" v-for="comment in comments">
                        <div class="card-content">
                            <div class="media">
                                <div class="media-left">
                                    <img src={{ asset("images/profile/") }}@{{comment.user.avatar}} style='height:50px; width:50px' /> 
                                </div>
                                <div class="media-content">   
                                    <p class="subtitle is-6">@{{comment.user.firstname}} said...</p>
                                    <p>
                                        @{{comment.body}}
                                    </p>
                                    <span style="color: #aaa;" class="is-size-7">on @{{comment.created_at}}</span>
                                </div>
                            </div>
                        </div>
                    </div>

{{comment.user.firstname}说

@{{comment.body}

关于{comment.created_at}
这是我的javascript

@section('scripts')
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          comments: {},
          commentBox: '',
          post: {!! $post->toJson() !!},
          user: {!! Auth::check() ? Auth::user()->toJson() : 'null' !!}
        },
        mounted(){
          this.getComments();
        //   this.listen();
        },
        methods:{
          getComments(){
            axios.get(`/api/posts/${this.post.id}/comments`)
              .then((response) => {
                this.comments = response.data
              })
              .catch(function(error){
                console.log(error);
              })
          },


        }
      });

    </script>
@节(“脚本”)
const app=新的Vue({
el:“#应用程序”,
数据:{
评论:{},
评论框:“”,
post:{!!$post->toJson()!!},
用户:{!!Auth::check()?Auth::user()->toJson():'null'!!}
},
安装的(){
这个.getComments();
//这个;
},
方法:{
getComments(){
get(`/api/posts/${this.post.id}/comments`)
。然后((响应)=>{
this.comments=response.data
})
.catch(函数(错误){
console.log(错误);
})
},
}
});
先谢谢你


arnel

不能在HTML属性中使用Vue插值。必须绑定表达式并用引号将其括起来。注
:src
v-bind:src
的缩写

<img :src="'{{ asset("images/profile/") }}' + comment.user.avatar">

什么是
comment.user.avata
r:\asset(“images/profile/”)}{{comment.user.avatar}}}使用此添加一个接一个确保在需要时放入$,如{$comment.user.avatar}注释是对象或路由名称??您尝试获取图像的方式是blade中的JavaScript(vue.js),您应该像
{$comment->user->avatar}一样获取图像
注释部分正在使用vue.js在v-for=“comment in comments”中循环。。如果我使用$comment->user->avatar,它会像这样显示每个记录@{comment.body},如果我给我这个变量$comment,它就找不到了。
'http://localhost:89/images/profile/' + comment.user.avatar