composition-api-converter
composition-api-converter copied to clipboard
Spread from function return unsupported in object options
Object spread is not currently supported and probably could be handled with some ugly code (unfortunately).
Input:
const computed = { value() { return this.count + 1; } };
export default {
props: {
count: Number,
},
computed: {
...computed,
}
}
Could be:
import { computed } from 'vue';
const _computed = { value() { return this.count + 1; } };
export default {
setup(props, context) {
const ctx = { ...props, ...context };
return {
...Object.keys(_computed).reduce((acc, key) => {
acc[key] = computed(_computed[key].bind(ctx))
return acc;
}, {})
}
}
}
The same applies to methods and data.