Skip to content

Commit

Permalink
fix(vue2): 兼容webpack5下app端部分静态资源引用不到
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Apr 1, 2024
1 parent 7cc85ad commit ce69fd1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vue-cli-plugin-uni/lib/app-plus/getUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ module.exports = function (url, options) {
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign

url = url && url.__esModule ? url.default : url

let isAbsoluteFile = false
if (typeof url !== 'string') {
if (url.protocol && url.protocol === 'file:' && url.pathname) {
isAbsoluteFile = true
url = url.pathname
} else {
return url
Expand All @@ -30,8 +31,11 @@ module.exports = function (url, options) {
if (/["'() \t\n]/.test(url) || options.needQuotes) {
return '"'.concat(url.replace(/"/g, '\\"').replace(/\n/g, '\\n'), '"')
}
if (isAbsoluteFile) {
return url
}
if (url.indexOf('/') === 0) {
return url.substr(1)
}
return url
}
}

0 comments on commit ce69fd1

Please sign in to comment.