Skip to content

Conversation

@FireBushtree
Copy link

  1. use this code, after click button, the text style will change to 'font-size: 12px'
<script setup>
import { ref } from 'vue'

const style = ref({ color: 'red' })
function handleClick() {
  style.value = { fontSize: '12px' }
}
</script>

<template>
  <h1 :style="style">Hello World</h1>
  <button @click="handleClick">change style</button>
</template>
  1. but this code, after click button, the text style will change to 'color: red; font-size: 12px'. the 'color: red' do not be removed
<script setup>
import { ref } from 'vue'

const style = ref('color: red')
function handleClick() {
  style.value = { fontSize: '12px' }
}
</script>

<template>
  <h1 :style="style">Hello World</h1>
  <button @click="handleClick">change style</button>
</template>

@yyx990803
Copy link
Member

Thanks for the PR - however I think #10373 is a cleaner fix as it avoids allocating a temporary object (we only need the keys).

@yyx990803 yyx990803 closed this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants