omi icon indicating copy to clipboard operation
omi copied to clipboard

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

Open WaterAndBin opened this issue 11 months ago • 1 comments

这是在OMI的代码

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的代码

<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,请问一下这个情况要如何解决?非常感谢

WaterAndBin avatar Jan 15 '25 10:01 WaterAndBin

触发不了dom的 setAttribute 就传不下去

dntzhang avatar Jan 16 '25 01:01 dntzhang