我有两个图像,一个绿色复选标记和一个灰色复选标记。当用户选中或取消选中列表中的项目时,这些会显示/隐藏。我遇到的问题是,当使用 缩小应用程序的图像时grunt-contrib-imagemin
,这两个图像ng-src
不会更改为缩小后的图像名称。任何想法为什么会发生这种情况以及如何解决它?
<img ng-if="item.checkedState === 'unchecked'" ng-src="images/unchecked.png" ng-click="changeCheckedState(item)">
<img ng-if="item.checkedState === 'checked'" ng-src="images/checked.png" ng-click="changeCheckedState(item)">
我的 usemin 任务:
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
}
}
编辑:通过测试@Tony Barnes 解决方案:
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images'],
patterns: {
html: [
[/<img[^\>]*[^\>\S]+ng-src=[""]([^'"\)#]+)(#.+)?["']/gm, 'Update the HTML with non standard ng-src attribute on img']
]
}
}
}
脚本和样式的其他 src 名称失败,即文件vendors132918.js
进入vendor.js
其中,然后由于未调用文件而src
引发错误。是什么导致其他人在这里失败?据我所知,除了图像上的 src 之外,模式不应该改变任何东西..404 not found
vendor.js
src