Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript方法,打开AMIS的dialog,好像toast,怎么实现? #10855

Open
wanquantong opened this issue Aug 30, 2024 · 8 comments
Open
Labels
doc optimizing document

Comments

@wanquantong
Copy link

wanquantong commented Aug 30, 2024

实现场景:

javascript方法,打开AMIS的dialog,好像toast,怎么实现?相关文档在哪?
我想用javascript调用,toast是可以用的,但dialog要怎么实现呢?
function tips() {
amisLib.toast.info('消息通知');
}

存在的问题:

https://aisuda.bce.baidu.com/amis/zh-CN/docs/extend/ui-library
使用 amis 公共方法
具体有哪些可以参考 https://github.com/baidu/amis/blob/master/src/index.tsx
这个链接打不开!

当前方案:

就像toast方法,amisLib.toast.info('消息通知'); 是可以用的。

let amis = amisRequire('amis/embed');
let amisLib = amisRequire('amis');
let amisScoped = amis.embed('#root', {
  type: 'page',
  title: '表单页面',
  body: {
    type: 'form',
    mode: 'horizontal',
    api: '/saveForm',
    body: [
      {
        type: 'button',
        label: '按钮',
        onClick: () => {
          amisLib.toast.info('消息通知');
        }
      }
    ]
  }
});
Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@github-actions github-actions bot added the doc optimizing document label Aug 30, 2024
@2betop
Copy link
Collaborator

2betop commented Aug 30, 2024

@wanquantong
Copy link
Author

https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/event-action#toast-%E6%8F%90%E7%A4%BA 用这个动作就能弹出

我想用javascript调用,toast是可以用的,但dialog要怎么实现呢?
function tips() {
amisLib.toast.info('消息通知');
}

@2betop
Copy link
Collaborator

2betop commented Aug 30, 2024

弹窗没有功能方法可以弹出,应该类似这样去用 component <Modal show={this.state.show} onClose={handleClose}><p>Contdents</p></Modal>

@lhtuling
Copy link

lhtuling commented Sep 4, 2024

你如果是强提示用alert和confirm可以
其他的你可能思路不对了,换方式吧不应该这样用!

image

image

@lhtuling
Copy link

lhtuling commented Sep 4, 2024

Amis低代码前端框架交流群【QQ1群】:717791727
Amis低代码前端框架交流群【QQ2群】:721182449

@wanquantong
Copy link
Author

你如果是强提示用alert和confirm可以 其他的你可能思路不对了,换方式吧不应该这样用!

image

image

我是想用JS代码触发打开AMIS的某一个dialog,可以实现吗?

@lhtuling
Copy link

lhtuling commented Sep 6, 2024

我是想用JS代码触发打开AMIS的某一个dialog,可以实现吗?

测了下可以的,比较绕一点,首先用definitions定义弹窗
然后通过暴露的amisScoped调用弹窗窗口方法就行了,也是个解决方法

Amis低代码前端框架交流群【QQ 1群】:717791727
Amis低代码前端框架交流群【QQ 2群】:721182449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc optimizing document
Projects
None yet
Development

No branches or pull requests

3 participants