laravel - 如何使用 VueJS (+ Laravel) 自动显示模态
问题描述
基本上我希望我在网站上的模态仅在周六下午 6 点到周日下午 6 点自动出现。
使用 vuejs (+ laravel) 怎么可能?如果我在 vuejs 中添加一些脚本可以吗?如果是,那怎么办?因为我有问题,所以我在互联网上找不到适合我的确切解决方案。
谢谢
解决方案
<script>
export default {
data() {
return {
showModal: false
};
},
mounted(){
let currentDate = new Date();
if ((currentDate.getDay() == 0 && currentDate.getHours() < 18 )
|| (currentDate.getDay() == 6 && currentDate.getHours() > 18)) {
this.showModal = true
}
}
}
</script>
推荐阅读
- c++ - 背景图像上的OpenGL透明对象
- reactjs - 在 reactnative 中创建适当的组件
- reactjs - 警告:您似乎正在使用 Firebase JS SDK 的开发版本
- r - 计算单列中连续日期之间的天数
- amazon-web-services - 来自cli的aws ec2实例IP地址 aws ec2 describe-instances
- c# - 从回调调用时,ASP.NET Core SignalR Clients 对象处理异常
- vba - 如果存在则使用 tab1,否则使用 tab2
- javascript - 404 错误快速路由
- php - Laravel:有效地求和嵌套关系(渴望加载)
- python - Python 3.5 JSON 序列化 Decimal 对象