Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
vue-facing-decorator
Advanced tools
Welcome to suggest and contribute. Message me on github.
npm install -S vue-facing-decorator
import {
Component,
Ref,
Watch,
Prop,
Inject,
Base,
} from "vue-facing-decorator";
//super class, DO NOT SUPPORT ANY DECORATOR now
class Sup extends Base {
//reactivity super property
supProperty = "supProperty";
//super method
supMethod() {}
//super getter
get supGetter() {
return "supGetter";
}
}
//component class
@Component({
//OPTION, component name
name: "MyComponent",
//OPTION, emits
emits: ["update:modelValue"],
//OPTION, provide object or function(this:Comp){return {foo:'bar'}}
provide: {
provideKey: "provideValue",
},
//OPTION, use modifier to modify component option built by vue-facing-decorator
modifier: (option: any) => {
console.log("generated optoin", option);
option.methods ??= {};
option.methods.method2 = function () {
console.log("method2");
};
return option;
},
})
export default class Comp extends Sup {
//create a ref
@Ref
readonly ref!: HTMLDivElement;
//create a prop
@Prop({
//prop options
required: true,
default: "default prop",
type: String,
validator(v: string) {
console.log("prop validator", v);
return true;
},
})
readonly prop!: string;
//v-model default prop
@Prop({
required: true,
type: Number,
})
readonly modelValue!: number;
//reactivity property
property = "property";
//getter
get getter() {
return "getter";
}
//method
method() {
//call vue api
this.$forceUpdate();
//set reactivity property
this.property += ">";
//trigger update v-model
this.$emit("update:modelValue", this.modelValue + 1);
}
//create a watcher
@Watch("property", {
//watcher options
deep: true,
immediate: true,
flush: "post",
})
propertyWatcher(newv: string, oldv: string) {
console.log("property changed", newv, oldv);
}
//inject from acient components
@Inject({
//inject options
default: "defult value",
from: "provideAcientKey",
})
provideAcientKeyAlias!: string;
mounted() {
//vue lifecycle
console.log(
this.ref,
this.getter,
this.property,
this.supProperty,
this.supGetter,
this.prop,
this.provideAcientKeyAlias
);
}
}
is equal to
import { defineComponent} from "vue";
export default defineComponent({
name: "MyComponent",
emits: ["update:modelValue"],
provide: {
provideKey: "provideValue",
},
inject: {
provideAcientKeyAlias: {
default: "defult value",
from: "provideAcientKey",
},
},
data() {
return {
supProperty: "supProperty",
property: "property",
};
},
methods: {
supMethod() {},
method() {
this.$forceUpdate();
this.$emit("update:modelValue", this.modelValue + 1);
},
method2() {
console.log("method2");
},
},
watch: {
property: function (newv: string, oldv: string) {
console.log("property changed", newv, oldv);
},
},
computed: {
supGetter() {
return "supGetter";
},
getter() {
return "getter";
},
ref() {
this.$refs["ref"];
},
},
props: {
prop: {
required: true,
default: "default prop",
type: String,
validator: function (v: string) {
console.log("prop validator", v);
return true;
} as any, // type error
},
modelValue: { type: Number, required: true },
},
mounted() {
console.log(
this.ref,
this.property,
this.supProperty,
this.getter,
this.supGetter,
this.prop,
(this as any).provideAcientKeyAlias //type error
);
},
});
FAQs
Vue typescript class and decorator based component.
The npm package vue-facing-decorator receives a total of 10,563 weekly downloads. As such, vue-facing-decorator popularity was classified as popular.
We found that vue-facing-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.