Closed tuhongwei closed 6 years ago
Your manifest file looks like:
{
"img-btn-ok.png": "img-btn-ok-88553322.png",
"img-btn-false.png": "img-btn-false-aa5588ff.png",
"img-btn-read.png": "img-btn-read-bb001199.png"
}
? You need js code like next:
switch(status) {
case 'ok':
imgSrc = 'img-btn-ok.png';
break;
case 'false':
imgSrc = 'img-btn-false.png';
break;
case 'read':
imgSrc = 'img-btn-read.png';
break;
}
$(element).attr('src', imgSrc);
Then gulp-rev-collector replaces names in switch - case
block corectly.
yes, you are right,At present, I solve the problem like this. But when the "status" is quite a lot, it is troublesome to list ony by one. So are there other solutions?
Now there is a problem, I use "require.ensure" to generate a script dynamically,but this script can't be replaced,how this problem be solved?
show me an exsamle of require.ensure usage. I don't undersand the problem.
I close the issue.
Now, I have a demand in my js files. I need to change the img dynamically according to the "status". So the code is "$(element).attr('src', 'img-btn' + status + '.png');". The status is a variable and is varying. In this case, the replacement can't work properly, because can't the img src.