<template>
  <span>{{ value || "- -" }}</span>
</template>

<script>
export default {
  name: "ComputedInput",
  props: {
    // v-model
    value: {
      type: [Number, String],
      require: true,
    },
    // v-model
    formatter: {
      type: Function,
      default: () => {},
      require: true,
    },
    // 源数据
    source: {
      type: Object,
      require: true,
    },
  },
  data() {
    return {};
  },
  computed: {
    newSource() {
      return this.$props.source;
    },
  },
  watch: {
    newSource: {
      handler: function (newProp) {
        const { formatter } = this.$props;
        this.$emit("input", formatter(newProp));
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {},
  created() {
   
  },
  mounted() {},
  destroyed() {},
};
</script>
<style scoped></style>
