Skip to content

Instantly share code, notes, and snippets.

@pascalbaljet
Last active January 21, 2021 12:57
Show Gist options
  • Save pascalbaljet/db3e810a69a4a854588d50d87ddfc5a8 to your computer and use it in GitHub Desktop.
Save pascalbaljet/db3e810a69a4a854588d50d87ddfc5a8 to your computer and use it in GitHub Desktop.
<script>
import Vue from "vue";
export default {
props: ["default"],
data() {
return {
attributes: {},
};
},
mounted() {
if (typeof this.default === "object") {
this.attributes = this.default;
}
},
render() {
const vm = this;
const props = new Proxy(
{
attributes: vm.attributes,
},
{
get: (target, key) => {
if (key === "attributes") {
return vm.attributes;
}
if (key === "__ob__") {
return vm["__ob__"];
}
if (key === "_isVue") {
return false;
}
return vm.attributes[key];
},
set(target, key, value) {
Vue.set(vm.attributes, key, value);
return true;
},
}
);
return this.$scopedSlots.default(props);
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment