File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
src/platforms/mp/compiler/codegen Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const objectToStringVisitor = {
33
33
const keyStr = getStrByNode ( propertyItem . key , true )
34
34
const key = keyStr ? hyphenate ( keyStr ) : keyStr
35
35
const { code : val } = generate ( t . ExpressionStatement ( propertyItem . value ) )
36
- return `'${ key } :' + ${ val . slice ( 0 , - 1 ) } + ';'`
36
+ return `'${ key } :' + ( ${ val . slice ( 0 , - 1 ) } ) + ';'`
37
37
} ) . join ( '+' )
38
38
39
39
const p = template ( expression ) ( { } )
Original file line number Diff line number Diff line change @@ -217,12 +217,17 @@ describe('指令', () => {
217
217
it ( 'v-bind:style' , ( ) => {
218
218
assertCodegen (
219
219
`<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }">111</div>` ,
220
- `<template name="a"><view class="_div" style=" {{('color:' + activeColor + ';' + 'font-size:' + fontSize + 'px' + ';')}}">111</view></template>` ,
220
+ `<template name="a"><view class="_div" style=" {{('color:' + activeColor + ';' + 'font-size:' + (fontSize + 'px') + ';')}}">111</view></template>` ,
221
+ { name : 'a' }
222
+ )
223
+ assertCodegen (
224
+ `<div v-bind:style="{ color: a === b ? activeColor : color, fontSize: fontSize + 'px' }">111</div>` ,
225
+ `<template name="a"><view class="_div" style=" {{( 'color:' + (a === b ? activeColor : color) + ';' + 'font-size:' + (fontSize + 'px') + ';')}}">111</view></template>` ,
221
226
{ name : 'a' }
222
227
)
223
228
assertCodegen (
224
229
`<div v-bind:style="[{ color: activeColor, fontSize: fontSize + 'px' }]">111</div>` ,
225
- `<template name="a"><view class="_div" style=" {{['color:' + activeColor + ';' + 'font-size:' + fontSize + 'px' + ';']}}">111</view></template>` ,
230
+ `<template name="a"><view class="_div" style=" {{['color:' + activeColor + ';' + 'font-size:' + ( fontSize + 'px') + ';']}}">111</view></template>` ,
226
231
{ name : 'a' }
227
232
)
228
233
assertCodegen (
You can’t perform that action at this time.
0 commit comments