<template>
  <div>
    <slot :value="value" :time="time">
      {{ id ? value : "未配置" }}
    </slot>
  </div>
</template>

<script>
export default {
  props: ["id"],
  name: "f-tag",
  inject: ["registerTag"],
  watch: {
    id() {
      if (this.id) {
        this.registerTag(this);
      }
    }
  },
  data() {
    return {
      value: null,
      unit: null,
      time: null
    };
  },
  methods: {
    setValue(v, time) {
      this.value = v;
      this.time = time;
      this.$emit("on-change", v);
    },
    setUnit(v) {
      this.unit = v;
    }
  },
  mounted() {
    if (this.id) {
      this.registerTag(this);
    }
  }
};
</script>

<style scoped></style>
