Coder Social home page Coder Social logo

Comments (4)

LAMMUpro avatar LAMMUpro commented on June 2, 2024

@nwind @TeCHiScy @luckyufei @weien601
大佬们,怎么办呀,找了一圈文档,这个问题貌似解决不了?(在doAction setValue的同时触发组件change事件)

from amis.

2betop avatar 2betop commented on June 2, 2024

解决不了,动作里面不会触发事件,之前 @hsm-lv 故意这么设计的

from amis.

LAMMUpro avatar LAMMUpro commented on June 2, 2024

触发的话有什么隐患吗?

我自定义了一个事件,用于平替setValue,以下是demo

// 动作定义
interface IUpdateValueAction extends ListenerAction {
  actionType: 'updateValue';
  args: {
    value: any, // 动作参数1
  };
}

/**
 * 更新组件数据,并触发组件change事件
 */
export class UpdateValueAction implements RendererAction {
  run(action: IUpdateValueAction, renderer: ListenerContext, event: RendererEvent<any>): Promise<RendererEvent<any> | void> {
    
    event.context.scoped.doAction({ ...action, actionType: 'setValue'});

    /** 根据组件id拿到组件实例 */
    const component = event.context.scoped.getComponentById(action.id);

    if (component) {
      component.changeValue(action.data);
    }

    return Promise.resolve(event);
  }
}

// 注册自定义动作
registerAction('updateValue', new UpdateValueAction());

from amis.

hsm-lv avatar hsm-lv commented on June 2, 2024

当前确实没有支持间接触发change,不过有支持的计划

from amis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.