From 717486946ac2d23ee8689fa74f0329acf6f61a42 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 11 May 2020 17:25:26 +0800 Subject: [PATCH] fix(v3): asset url --- packages/uni-template-compiler/lib/asset-url.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/uni-template-compiler/lib/asset-url.js b/packages/uni-template-compiler/lib/asset-url.js index 653e38959..8ffc8986f 100644 --- a/packages/uni-template-compiler/lib/asset-url.js +++ b/packages/uni-template-compiler/lib/asset-url.js @@ -68,10 +68,15 @@ function rewrite (attr, name, options) { .replace('"@/', '"/') .replace('"~@/', '"/') } - // h5 - if (options.h5) { + // v3,h5 + const needRequire = options.service || options.view || options.h5 + if (needRequire) { attr.value = urlToRequire(attr.value.slice(1, -1)) - if (attr.value.startsWith('require("') && options.publicPath === './') { // require + if ( + options.h5 && + options.publicPath === './' && + attr.value.startsWith('require("') + ) { // require // h5 且 publicPath 为 ./ (仅生产模式可能为./) attr.value = `(${attr.value}).substr(1)` } -- GitLab