define-jsx-model
Advanced tools
Comparing version
@@ -1,1 +0,4 @@ | ||
export declare function defineJsxModel<T extends object, K extends Exclude<keyof T, symbol>>(props: T, name: K, defaultValue?: T[K]): any; | ||
export declare function defineJsxModel< | ||
T extends object, | ||
K extends Exclude<keyof T, symbol> | ||
>(props: T, name: K, defaultValue?: T[K]): any; |
22
main.js
import { computed, getCurrentInstance, ref } from "vue"; | ||
export function defineJsxModel(props, name, defaultValue = props[name]) { | ||
const value = ref(defaultValue); | ||
const ins = getCurrentInstance(); | ||
return computed({ | ||
get() { | ||
return value.value; | ||
}, | ||
set(v) { | ||
value.value = v; | ||
ins === null || ins === void 0 ? void 0 : ins.emit(`update:${name}`, v); | ||
}, | ||
}); | ||
const value = ref(defaultValue); | ||
const ins = getCurrentInstance(); | ||
return computed({ | ||
get() { | ||
return value.value; | ||
}, | ||
set(v) { | ||
value.value = v; | ||
ins === null || ins === void 0 ? void 0 : ins.emit(`update:${name}`, v); | ||
}, | ||
}); | ||
} |
{ | ||
"name": "define-jsx-model", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "#### 介绍 适用于vue3中的jsx版本的defineModel", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
58
5.45%4125
-0.87%