Socket
Socket
Sign inDemoInstall

@vue/babel-sugar-v-model

Package Overview
Dependencies
61
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vue/babel-sugar-v-model

Babel syntactic sugar for v-model support in Vue JSX


Version published
Weekly downloads
895K
increased by4.21%
Maintainers
3
Install size
2.49 MB
Created
Weekly downloads
 

Readme

Source

@vue/babel-sugar-v-model

Syntactic sugar for v-model in JSX.

Babel Compatibility Notes

  • This repo is only compatible with Babel 7.x, for 6.x please use vuejs/babel-plugin-transform-vue-jsx

Usage

Install the dependencies:

# for yarn:
yarn add @vue/babel-sugar-v-model
# for npm:
npm install @vue/babel-sugar-v-model --save

In your .babelrc:

{
  "plugins": ["@vue/babel-sugar-v-model"]
}

However it is recommended to use the configurable preset instead.

Details

This plugin adds v-model to the JSX and tries to mirror the same behaviour as in vue-template-compiler, with a few differences:

  1. You should use underscore (_) instead of dot (.) for modifiers (vModel_trim={this.test})
  2. It is recommended to use camelCase version of it (vModel) in JSX, but you can use kebab-case too (v-model).
export default {
  data: () => ({
    test: 'Hello World',
  }),
  render(h) {
    return (
      <div>
        <input type="text" vModel_trim={this.test} />
        {this.test}
      </div>
    )
  },
}

FAQs

Last updated on 25 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc