#942·omi

OMI接收不了Vue传过来的方法

Author: WaterAndBinCreated Jan 15, 2025Updated Jan 16, 2025

这是在OMI的代码

typescript
import { h, tag, Component } from 'omi';
@tag('y-switch')
export default class YSwitch extends Component {
  static props = {
    beforeChange: {
      type: Function,
      default: null,
      changed(newValue: Function) {
        console.log(12312313);
        console.log(newValue);

        if (this instanceof YSwitch) {
          this.update();
        }
      }
    }
  };
  render(props: any) {
    console.log(props);
    return <div>hallo,omi</div>;
  }
}

这是在Vue的代码

xml
<script setup lang="ts">
import { ref } from 'vue'

const changeLoading = async () => {
  await new Promise((resolve) => setTimeout(resolve, 1000))
  return true
}
</script>

<template>
  <div>
    <div className="flex justify-center items-center">
      <y-switch :before-change="changeLoading"></y-switch>
      <y-switch :beforeChange="changeLoading"></y-switch>
    </div>
  </div>
</template>

获取到的beforeChange都是undefeind/null,请问一下这个情况要如何解决?非常感谢