【问题标题】:Gruntjs angularjs cordova image not loading upGruntjs angularjs cordova图像未加载
【发布时间】:2014-12-16 23:05:39
【问题描述】:

不知道我做错了什么。 这是 grunt 后我的 css 的样子,但我的实际图像文件名是

backgorund-with-logo.d623d8e2.jpg

.containor{
    min-height: 100%; 
    background: url('/images/backgorund-with-logo.d623d8e2.jpg') center 30% no-repeat;
    background-size: 100%;
}

Grunt 文件

usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']

            }
        },
imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

但是当我尝试在我的 android 设备上运行并通过 chrome 进行检查时 资源文件加载失败:///images/backgorund-with-logo.d623d8e2.jpg

请帮忙

【问题讨论】:

  • 您能否验证图像名称是 backgorund-with-logo.jpg 而不是 background-with-logo.jpg。也是android特有的问题吗?
  • 文件名没问题。我查看了图像文件夹并且图像存在。 android 和 ios 都在发生这种情况
  • 如果我没记错,它应该从文件中加载图像:///android_asset/www/images/... 但不知道该怎么做

标签: javascript css angularjs cordova gruntjs


【解决方案1】:

这不是最好的方法,但我通过删除 '/images/{,/}.{png,jpg,jpeg,gif,webp 阻止了缩小图像,svg}',来自 filerev。如果有更好的方法,请告诉我们

【讨论】:

    猜你喜欢
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 2017-04-20
    • 2013-07-07
    • 2018-09-25
    相关资源
    最近更新 更多