有这样一个模块代码(用于处理数据库):
use tokio_postgres::{NoTls, Error};
pub async fn hello() -> Result<(), Error> {
// Connect to the database.
let (client, connection) =
tokio_postgres::connect("host=localhost user=postgres", NoTls).await?;
// The connection object performs the actual communication with the database,
// so spawn it off to run on its own.
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
// Now we can execute a simple statement that just returns its parameter.
let rows = client
.query("SELECT $1::TEXT", &[&"hello …Run Code Online (Sandbox Code Playgroud) 有这样一段代码:
\n
<template>\n\n <div class="wrapper">\n </div>\n\n</template>\n\n<script>\n\nimport axios from \'axios\';\n\nexport default{\n\n created () {\n console.log(\'222\');\n this.getTrackerIdData();\n this.getTrackerData();\n },\n\n methods: {\n\n getTrackerIdData () {\n return axios.get("https://seo-gmbh.eu/couriertracker/json/couriertracker_api.php?action=tracking_new.create" , {\n })\n .then(response => {\n this.$store.commit(\'tracker/setTrackingKeyId\', response.data.data.tracking_new_key_id);\n this.$store.commit(\'tracker/setQrCodeUrl\', response.data.data.filename_qr_code_tracking_new);\n })\n .catch(function (error) {\n console.log(error);\n });\n },\n\n getTrackerData () {\n\n setInterval(()=>myTimer(this), 60000);\n\n function myTimer(th) {\n return axios.get("https://seo-gmbh.eu/couriertracker/json/couriertracker_api.php?action=get_tracking_data&key_id=" + th.$store.state.tracker.trackingKeyId , {\n })\n .then(response => {\n th.$store.commit(\'tracker/setTrackingServerData\', response.data.data.tracking_data);\n })\n .catch(function (error) {\n console.log(error);\n });\n }\n\n},\n\n }\n}\n</script>\nRun Code Online (Sandbox Code Playgroud)\n\n
\n当在项目中启动这样的解决方案时,服务器端开发人员告诉我,至少getTrackerIdData ()其一侧的请求方法可以工作两次!
\n将代码 ( console.log (\'222\');) …
该流程有一个字符串形式的开始日期:
'2020-03-02 06:49:05'
Run Code Online (Sandbox Code Playgroud)
以及流程完成日期:
'2020-03-02 07:05:02'
Run Code Online (Sandbox Code Playgroud)
问题:
从方法的角度来看,最正确的方法是什么 - 计算过程开始和结束之间的差异(以分钟为单位)?(如果在vue.jsor 中有任何内置方法,nuxt.js了解它们也会很有趣。)