如何在前端闪烁消息? [英] How to flash a message in front-end?

查看:194
本文介绍了如何在前端闪烁消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在此页面上闪烁消息: https://octobercms.com/docs/ui/flashmessage

How can I flash a message like on this page: https://octobercms.com/docs/ui/flashmessage

我应该包括什么?在哪里?

What should I include and where?

我确实需要在用户提交某些表单后显示一条消息. 在Octobercms论坛上,我发现了一些困难的方法.

Exactly I need flash a message after an user submitted some form. On Octobercms forum I find kind of difficult ways to do it.

推荐答案

将此属性 data-request-flash 包含在表单标签中,如下所示

Include this attribute data-request-flash in your form tag like below

<form data-request-flash >

并在表单所在的同一页面/文件上添加以下代码

and add below code on same page/file where your form is

{% flash %}
    <p
        data-control="flash-message"
        class="flash-message fade {{ type }}"
        data-interval="5">
        {{ message }}
    </p>
{% endflash %}

,并假设您的方法类似于下面的组件,然后添加Flash消息.

and suppose your method is like below on component then add flash message like this.

<?php 
public function onCustomerRegister(){
    Flash::success("your message is here");
}
?>  

这篇关于如何在前端闪烁消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆