【问题标题】:How to retrieve images dynamically from server in Vuejs如何在Vuejs中从服务器动态检索图像
【发布时间】:2018-01-30 20:15:58
【问题描述】:
<img class="img-responsive" :src="'http://10.20.10.161:8000/content_images/'+video.image" >

代替http://10.20.10.161:8000,我需要一些预定义变量作为我的服务器应用程序的基本网址。

我该如何设置?

【问题讨论】:

    标签: vue.js


    【解决方案1】:

    &lt;img class="img-responsive" :src="getContentImageLink(video.image)" &gt;

    在 Vue DOM 中,我们将调用一个函数。

    getContentImageLink(video_image) { return this.$http.options.root + '/content_images/' + video_image; }

    然后在脚本中,我们将返回带有预定义基本 URL 的图像的完整链接,该基本 URL 必须在 main.js 文件中设置。

    Vue.http.options.root = 'http://10.20.10.161:8000'
    

    不错的选择,我必须这样做。 如果有人有更好的选择,请发表评论。

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 2015-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2015-11-17
      • 2012-11-25
      • 1970-01-01
      相关资源
      最近更新 更多