0
good morning:
 <html>
 <button type="button" class="btn btn-primary">Notifications <span class="badge badge-light">4</span>
 </button>


 <button type="button" class="btn btn-primary">Profile <span class="badge badge-light">9</span>
   <span class="sr-only">unread messages</span>
 </button>
</html>

在此处输入图像描述

现在我如何实现这些?例如像facebook,当我点击通知时会出现一个小子菜单

任何人都可以帮助我吗?谢谢

4

1 回答 1

0

您可以从控制器中的数据库获取通知,将它们放入变量中,然后将其传递给视图。

在视图本身中,您可以执行以下操作:

// $notificationsCount is the variable with number of notifications you passed to the 
view in your controller
<button type="button" class="btn btn-primary">Notifications 
    <span class="badge badge-light"><?php echo $notificationsCount ?></span>
</button>

如果您不想刷新页面,可以使用 ajax 或某种事件。例子:

$('#someElement').on('click', function () {
    //change value of the notification btn
});
于 2019-02-20T15:59:34.030 回答