0👍
To use typescript in Vue Options API you should wrap your Options components into defineComponent
export default defineComponent({
data: () => ({...}),
props: ['a', 'b'],
computed: {...},
// template: '...'
});
However, that won’t work with templates, if you don’t use tooling to use .vue
files (as templates are just strings, while in vue files they are seperate language)
If you want to switch to tooling, check out the latest Vue script setup
(I was rewriting .vue in Options into Script Setup, with some hand-made regex-based converter making half of work)
Maybe some component framework like https://quasar.dev/
Maybe with plugins like unplugin-auto-import
(removes need in importing often-used things like ref
of computed
)
- [Vuejs]-How do I properly strongly-type a reactive array whose elements are interfaced Class objects?
- [Vuejs]-How can I implement searching with vuejs and bootstrap-vue's form-input and form-checkbox components?
Source:stackexchange.com