本文整理汇总了TypeScript中vue-property-decorator.Watch函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Watch函数的具体用法?TypeScript Watch怎么用?TypeScript Watch使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Watch函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: imageUpdater
@Watch("image", { immediate: true })
imageUpdater() {
let metaImage = document.getElementById("meta-image") as HTMLMetaElement;
if (this.image) {
metaImage.content = this.image;
} else {
metaImage.content = window.location.origin + "/img/only-logo.png";
}
}
示例2: descriptionUpdater
@Watch("description", { immediate: true })
descriptionUpdater() {
let metaDescription = document.getElementById(
"meta-description"
) as HTMLMetaElement;
let metaOGDescription = document.getElementById(
"meta-og-description"
) as HTMLMetaElement;
metaOGDescription.content = this.description;
metaDescription.content = this.description;
}
示例3: metaUpdator
@Watch("$route.fullPath", { immediate: true })
metaUpdator() {
let link = document.getElementById("canonical-link") as HTMLLinkElement;
let metaUrl = document.getElementById("meta-url") as HTMLMetaElement;
let metaType = document.getElementById("meta-type") as HTMLMetaElement;
let metaImage = document.getElementById("meta-image") as HTMLMetaElement;
link.href = document.location.href;
metaUrl.content = document.location.href;
if (this.$route.name === routes.video.name) {
metaType.content = "video.other";
metaImage.content = `https://img.youtube.com/vi/${
this.$route.params[routes.video.params.id]
}/hqdefault.jpg`;
} else {
metaType.content = "website";
metaImage.content = window.location.origin + "/img/only-logo.png";
}
}
示例4: OnRouteChange
@Watch('$route')
OnRouteChange() {
if (this.device === DeviceType.Mobile && this.sidebar.opened) {
AppModule.CloseSideBar(false);
}
}
示例5: titleUpdater
@Watch("title", { immediate: true })
titleUpdater() {
document.title = this.title ? `vTyoob - ${this.title}` : "vTyoob";
let metaTitle = document.getElementById("meta-title") as HTMLMetaElement;
metaTitle.content = document.title;
}