【问题标题】:Laravel blade + vue render ajax data couple?Laravel Blade + vue 渲染 ajax 数据对?
【发布时间】:2018-05-12 06:33:20
【问题描述】:

我想用blade + vue写ajax渲染新闻。

<div id="news">
    <div class="l_news">
        <div class="post" v-for="post in posts">
            <div class="image" style="background: url({{ asset('images/car.jpg') }}) no-repeat center / cover">
                <div class="title">@{{ post.title }}</div>
            </div>
            <div class="desc">@{{ post.desc }}</div>
        </div>
    </div>
</div>

我在渲染帖子图像时遇到了一些问题。

但是我不能用

url({{ asset('@{{ post.image }}') }})

如何正确书写?

现在我正在使用 :style=""。

提前致谢!

【问题讨论】:

    标签: php ajax laravel-5 vue.js laravel-blade


    【解决方案1】:

    您不能在 v-for 中调用 php 函数,因为它超出了您的上下文。

    但也许你可以做到以下几点:

    :style="'background: url({{url('/images')}}" + '/' + post.image"
    

    只需将图片名称附加到您的网址即可。

    【讨论】:

      猜你喜欢
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 2015-09-12
      • 2015-08-19
      • 2021-07-26
      • 2019-04-23
      • 2021-05-09
      相关资源
      最近更新 更多