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

Set api won't trigger update? #683

Closed
gitHber opened this issue Apr 23, 2021 · 0 comments · Fixed by #692
Closed

Set api won't trigger update? #683

gitHber opened this issue Apr 23, 2021 · 0 comments · Fixed by #692

Comments

@gitHber
Copy link

gitHber commented Apr 23, 2021

here is two example about set api?
vue2

<template>
  <button @click="addA">Temp1 {{ obj.a }}</button>
</template>
<script>
export default {
  data() {
    return {
      obj: {},
    };
  },
  methods: {
    addA() {
      this.$set(this.obj, "a", "new property"); // It's work and dom update
    },
  },
};
</script>

vca

<template>
  <button @click="addA">Temp2 {{ obj.a }}</button>
</template>
<script>
import Vue from "vue";
import VueCompositionApi, {
  defineComponent,
  reactive,
  set,
} from "@vue/composition-api";

Vue.use(VueCompositionApi);

export default defineComponent({
  setup() {
    const obj = reactive({});
    const addA = () => {
      set(obj, "a", "new property"); // Obj change but dom not update
    };
    return {
      obj,
      addA,
    };
  },
});
</script>

Here is a demo

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 a pull request may close this issue.

1 participant