Gathering detailed insights and metrics for vue-use-model-helpers
Gathering detailed insights and metrics for vue-use-model-helpers
npm install vue-use-model-helpers
Typescript
Module System
Node Version
NPM Version
51.2
Supply Chain
97.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
TypeScript (93.69%)
JavaScript (6.31%)
Total Downloads
2,273
Last Day
1
Last Week
4
Last Month
13
Last Year
154
3 Stars
20 Commits
3 Watching
5 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
4.0.0-beta.4
Package Id
vue-use-model-helpers@4.0.0-beta.4
Unpacked Size
12.13 kB
Size
4.24 kB
File Count
14
NPM Version
8.19.3
Node Version
16.19.0
Publised On
01 Mar 2023
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
4
Compared to previous week
Last month
44.4%
13
Compared to previous month
Last year
-72.1%
154
Compared to previous year
1
1
This library provides a helper to convert a component's property to a local Ref you can mutate when you are using composition-api, simplifying the management of the custom v-model
and .sync
This library works with Vue 2.7+ and Vue 3
When you create a component that gets a property and then needs to mutate it into the component you get this vue warn
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component
You need to copy the property value to a local value to use in the component,
Also should update your local value when the property value changes
If the property is a v-model
or uses .sync
you also must take care of emitting an event when your local value changes to keep updated the property value in the parent component.
The motivation of this library is simplifying this task and reducing the amount of repetitive code.
Vue 2.7+ or 3.x
If you need support for vue 2.5+ and composition Api, please use the 2.x
version
npm i vue-use-model-helper@4 --save
or
yarn add vue-use-model-helper@4
In your component:
1import { useLocalModel } from 'vue-use-model-helpers' 2 3export default defineComponent({ 4 ... 5 props: { 6 value: String 7 } , 8 setup(props) { 9 10 const localValue = useLocalModel(props, 'value') 11 12 return { 13 localValue 14 } 15 } 16 ... 17})
Now you can use localValue
in your component, and the helper takes care of sync the values, emit the update event, etc
The component can work with both value
and .sync
emitting the correct event to keep the property updated
1<template> 2 <div> 3 {{ localCounter }} 4 <button @click="increaseCounter"></button> 5 </div> 6</template> 7import { useLocalModel } from 'vue-use-model-helpers' 8 9export default defineComponent({ 10 ... 11 props: { 12 value: String, 13 counter: Number // This propery has .sync in the parent component 14 } , 15 setup(props) { 16 const localValue = useLocalModel(props, 'value') 17 const localCounter = useLocalModel(props, 'counter') 18 19 const increaseCounter = () => { 20 localCounter.value = localCounter.value + 1 21 } 22 23 return { 24 localValue, 25 localCounter, 26 increaseCounter 27 } 28 } 29 ... 30})
Proudly created in Vigo and around its local community
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is archived
Details
Reason
security policy file not detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More