Skip to content

Instantly share code, notes, and snippets.

@chulman444
Last active August 3, 2019 07:21
Show Gist options
  • Save chulman444/6fe2db81cadddb9e9525cc702d542216 to your computer and use it in GitHub Desktop.
Save chulman444/6fe2db81cadddb9e9525cc702d542216 to your computer and use it in GitHub Desktop.
Simple reactivity demo. Adding new property
<template lang="pug">
div
div {{ entry.foo.hi }}
v-btn(@click="onBtnClick") click
</template>
<script lang="ts">
import { Vue, Component } from "nuxt-property-decorator"
@Component
export default class TestPage extends Vue {
entry = { foo: { bar: "baz" } }
onBtnClick() {
if('hi' in this.entry.foo) {
(<any>this.entry.foo).hi += 1
}
else {
// Doesn't work with
// this.entry.foo.hi = 1
this.$set(this.entry.foo, "hi", 1)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment