【问题标题】:package image works in style but not in img包图像在样式中有效,但在 img 中无效
【发布时间】:2016-05-29 23:04:14
【问题描述】:

我正在使用 ng-cordova,我已将图像存储在 cordova.file.dataDirectory 的子目录中,无法通过 img[src] 加载它,但我可以通过 [style] 加载它,我是否需要做任何特别的事情让它在img[src] 中工作?

$scope

{
"Image":"file:///data/data/{package}/files/{subdir}/{imagename}.png"
}

作品

<div style="background-image:url({{Image}})"></div>

不起作用

<img src="{{Image}}" />

【问题讨论】:

    标签: html css cordova ngcordova html5-filesystem


    【解决方案1】:

    这是一个愚蠢的错误,我忘了检查我的$compileProvider 服务。我让它为filesystem 工作,但不是file

    $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|local|data|filesystem|file):/);
    

    【讨论】:

      猜你喜欢
      • 2013-10-22
      • 2015-08-07
      • 1970-01-01
      • 2015-05-11
      • 2018-05-18
      • 1970-01-01
      • 2020-04-03
      • 1970-01-01
      • 2014-10-14
      相关资源
      最近更新 更多