uniapp中的一个标签<p :style="now >= item.start_second && now <= item.end_second ? 'color:#2069DD' : 'color:#6a6464'"></p>已经这样添加了动态style那么如何再继续在这个动态的style中继续添加属性
时间: 2024-04-13 10:29:25 浏览: 85
在UniApp中,你可以使用三元表达式来动态添加多个属性到style属性中。例如,你可以按照以下方式修改代码:
```html
<p :style="now >= item.start_second && now <= item.end_second ? 'color:#2069DD; font-size: 16px;' : 'color:#6a6464; font-size: 14px;'"></p>
```
在上面的示例中,我添加了一个`font-size`属性,并根据条件判断使用不同的值。你可以根据需要继续添加其他属性,只需在三元表达式中使用分号 `;` 分隔每个属性即可。
相关问题
<p :style="{now>= item.start_second && now <= item.end_second ? 'color:#2069DD' : 'color:#595555',fontSize: fSize}"> </p>这个标签有什么错误如何修改
在你提供的代码中,有一个错误在于`fontSize: fSize`的部分。在Vue/UniApp中,绑定style属性的对象应该是一个计算属性或者是一个data中的属性,而不是直接使用变量。
你可以将`fontSize`定义为一个计算属性或者是data中的属性,并在template中引用它。例如:
```html
<template>
<p :style="{now >= item.start_second && now <= item.end_second ? 'color:#2069DD' : 'color:#595555', fontSize: dynamicFontSize}"></p>
</template>
<script>
export default {
data() {
return {
dynamicFontSize: '14px', // 初始值
now: 0, // 根据实际情况设置now的初始值
item: {
start_second: 0, // 根据实际情况设置item的值
end_second: 0 // 根据实际情况设置item的值
}
};
},
computed: {
fSize() {
// 根据实际情况计算fontSize的值
return this.now >= this.item.start_second && this.now <= this.item.end_second ? '16px' : '14px';
}
}
};
</script>
```
在上面的示例中,我将`fontSize`定义为`dynamicFontSize`属性,并使用计算属性`fSize`来根据条件计算其值。然后在template中使用`:style`绑定动态style,并将`fontSize`设置为`dynamicFontSize`。
请根据你的实际需求修改示例中的初始值和计算属性的逻辑。
此代码执行后就直接结束了from analysis import CC from datetime import datetime, timedelta import schedule from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger import multiprocessing as mp import time def cc_job(): # 获取当天日期 date_today = datetime.today().strftime('%Y%m%d') # 获取当前时间 now_time = datetime.now().time().strftime('%H:%M:%S') # 获取1小时前整点开始时间 one_hour_ago_start = (datetime.now() - timedelta(hours=1)).time().strftime('%H:00:00') # one_hour_ago_start = (datetime.now() - timedelta(hours=1)).time().strftime('%H:%M:%S') # 获取1小时前整点结束时间 one_hour_ago_end = (datetime.now() - timedelta(hours=1)).time().strftime('%H:59:59') # one_hour_ago_end = (datetime.now() - timedelta(hours=1)).time().strftime('%H:%M:%S') # print(one_hour_ago_start) # print(one_hour_ago_end) cc = CC(one_hour_ago_start, one_hour_ago_end, date=date_today) cc.wesocket_connect_new() def run(): schedule.every().hour.at(":39").do(cc_job) schedule.run_pending() # time.sleep(60) if __name__ == '__main__': # # p = mp.Process(target=run) # p.start() scheduler = BackgroundScheduler() trigger = CronTrigger(hour='*', minute='05', second='10') scheduler.add_job(cc_job, trigger=trigger) scheduler.start()
这段代码定义了一个cc_job函数,该函数会在每小时的39分执行。接下来,代码创建了一个后台任务调度器,使用CronTrigger在每小时的第5分10秒执行cc_job函数。最后,调用scheduler.start()方法启动调度器。
由于调度器是在后台执行的,因此程序并不会直接结束。但是,由于调度器没有设置退出条件,如果你想退出程序,需要手动终止程序运行。
此外,你需要确保你的CC类已经被正确导入并且可用。如果导入失败或者CC类存在问题,程序会因为无法调用cc_job函数而报错。
阅读全文
相关推荐
















