Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为div绑定一个字符串类型的style用来设置background-image:url('xxxxxx'),图片因为一些问题error了,当其他变量触发组件patch时,会再次请求这张图片 #1309

Closed
xiaojvmao opened this issue Jun 6, 2020 · 0 comments · Fixed by #1310

Comments

@xiaojvmao
Copy link

Version

3.0.0-beta.14

Reproduction link

https://codepen.io/403141449/pen/eYJNzed?editors=1011

Steps to reproduce

let { createApp, ref, reactive } = Vue;
createApp({
  setup() {
    let a = ref(0);
    let stringStyle = ref('background-image: url(http://cdn.normalhamal.online/4d98e41247d1e425894a.jpeg)');
    return {
      a,
      stringStyle,
    }
  }
}).mount("#app")
<div id="app">
  <div :style="stringStyle"></div>
  <button @click="a  ">
    {{ a }}    
  </button>
</div>

图片因为某些原因error了,当a的值改变时会再次请求这张图片

如果stringStyle没有修改background-image,不会再次请求这张图片

或者写成

let style = {
    backgroundImage: 'background-image: url(http://cdn.normalhamal.online/4d98e41247d1e425894a.jpeg)'
}

也不会再次请求这个图片

在vue2.6.11中没有这个问题

What is expected?

只请求一次图片

What is actually happening?

每次patch都会请求一次图片

underfin added a commit to underfin/vue-next that referenced this issue Jun 6, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant