Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/webpack-plugin/lib/platform/style/wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ module.exports = function getSpec ({ warn, error }) {
switch (prop) {
case bgPropMap.image: {
// background-image 支持背景图/渐变/css var
if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value)) {
if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value) || value === 'none') {
return { prop, value }
} else {
error(`Value of ${prop} in ${selector} selector only support value <url()> or <linear-gradient()>, received ${value}, please check again!`)
Expand Down Expand Up @@ -359,6 +359,13 @@ module.exports = function getSpec ({ warn, error }) {
error(`Property [${bgPropMap.all}] in ${selector} is abbreviated property and does not support CSS var`)
return false
}
// background: none
if (value === 'none') {
return [
{ prop: bgPropMap.image, value },
{ prop: bgPropMap.color, value: 'transparent' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要color吧?

]
}
const bgMap = []
const values = parseValues(value)
values.forEach(item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ function parseBgImage (text: string): {
type?: 'image' | 'linear'
src?: string
} {
if (!text) return {}
if (!text || text === 'none') return {}

const src = parseUrl(text)
if (src) return { src, type: 'image' }
Expand Down