diff --git a/active-rfcs/0000-define-options.md b/active-rfcs/0000-define-options.md new file mode 100644 index 00000000..8afa2572 --- /dev/null +++ b/active-rfcs/0000-define-options.md @@ -0,0 +1,108 @@ +- Start Date: 2022-02-13 +- Target Major Version: 3.x +- Reference Issues: https://github.com/vuejs/core/issues/5218 +- Implementation PR: https://github.com/vuejs/core/pull/5738 + +# Summary + +Introduce a macro in script setup, `defineOptions`, to use Options API in `script setup`, specifically to be able to set `name`, `inheritAttrs` and `render` in `script setup`. + +# Basic example + +```vue + +``` + +
+Compiled Output + +```js +const __default__ = { + name: 'Foo', + inheritAttrs: false +} +const setup = () => { + const slots = useSlots() + return { slots } +} +export default Object.assign(__default__, { + setup +}) +``` + +
+ +### JSX in `script-setup` + +```vue + +``` + +
+Compiled Output + +With [Babel plugin](https://github.com/vuejs/babel-plugin-jsx). + +```js +const __default__ = { + render() { + return h('h1', {}, () => 'Hello World') + } +} +const setup = () => {} +export default Object.assign(__default__, { + setup +}) +``` + +
+ +# Motivation + +This proposal is mainly to set the Options API using only `script setup`. + +We already have `