【发布时间】:2020-02-20 15:22:45
【问题描述】:
谁能帮我处理@Model 和@Emit 的装饰器? 我正在尝试更改单击我的组件的顺序并从此处使用文档:https://github.com/kaorun343/vue-property-decorator。 这是我的代码:
<template>
<button @click="onSortClick">Sort</button>
</template>
<script lang="ts">
import Vue from "vue";
import { Emit, Componet, Model } from "vue-property-decorator";
export default class MyButton extends Vue {
@Model("sort", { type: String, default: "none" }) readonly order!: string;
@Emit("sort")
onSortClick() {
const nextSortOrder = {
ascending: "descending",
descending: "none",
none: "ascending"
};
return nextSortOrder[this.order];
}
}
</script>
但是当我点击按钮时,变量“order”的值并没有改变。我是不是做错了什么?
【问题讨论】:
-
更多信息在这里会有帮助吗?你想在同一个组件中捕获一个发射事件吗?还是在父组件中?
标签: javascript typescript vue.js javascript-decorators