b4cfdcfb9f0be0108799a7be14037ea2a3e73b083ee952cbf731cb2b782e62243afe7d745c30233fb49da435c0c22dfdee75e280873a57c06d9db4a49979df 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ## @vue/babel-sugar-inject-h
  2. Syntactic sugar for automatic `h` inject in JSX.
  3. ### Babel Compatibility Notes
  4. - This repo is only compatible with Babel 7.x, for 6.x please use [vuejs/babel-plugin-transform-vue-jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx)
  5. ### Usage
  6. Install the dependencies:
  7. ```sh
  8. # for yarn:
  9. yarn add @vue/babel-sugar-inject-h
  10. # for npm:
  11. npm install @vue/babel-sugar-inject-h --save
  12. ```
  13. In your `.babelrc`:
  14. ```json
  15. {
  16. "plugins": ["@vue/babel-sugar-inject-h"]
  17. }
  18. ```
  19. However it is recommended to use the [configurable preset](../babel-preset-jsx/README.md) instead.
  20. ### Details
  21. This plugin automatically injects `h` in every method that has JSX. By using this plugin you don't have to always specifically declare `h` as first parameter in your `render()` function.
  22. ```js
  23. // Without @vue/babel-sugar-inject-h
  24. export default {
  25. render (h) {
  26. return <button />
  27. }
  28. }
  29. // With @vue/babel-sugar-inject-h
  30. export default {
  31. render () {
  32. return <button />
  33. }
  34. }
  35. ```