我的想法是,如果今天的日期大于或等于按鈕指向“x”或“y”的預期日期......
我不知道我可以把這個條件放在哪里(如果在檔案 .ts 或 .html 上):
var expectedDate = new Date ("2022/08/11")
var dates = expectedDate.toString()
var today = new Date().toISOString().split('T')[0];
if(today >= expectedDate) {
microsoftLogin()
}
else{...
googleLogin()
}
這是我在 .HTML 中的代碼在哪里是我的按鈕登錄我不知道是否可以在(點擊)上添加條件
<Button
width="70%"
height="40"
(tap)="CONDITION HERE"
text="Iniciar sesión"
class="login-submit"
row="2">
</Button>
uj5u.com熱心網友回復:
我對本機腳本了解不多,但您應該能夠在您的 TS 檔案中創建一個方法并在 HTML 中呼叫它
loginTapped() {
var expectedDate = new Date ("2022/08/11")
var dates = expectedDate.toString()
var today = new Date().toISOString().split('T')[0];
if(today >= expectedDate) {
microsoftLogin()
}
else{...
googleLogin()
}
}
<Button
width="70%"
height="40"
(tap)="loginTapped()"
text="Iniciar sesión"
class="login-submit"
row="2">
</Button>
希望這會有所幫助。
uj5u.com熱心網友回復:
這可能會對您有所幫助。
expectedDate=null;
today=null;
onLogin() {
this.expectedDate = new Date('2022/01/11');
this.today =new Date();
if(this.today.getTime() > this.expectedDate.getTime())
{
// today is greater than expected
this.microsoftLogin()
}
else
{
// today is less than expected
this.googleLogin()
}
}
microsoftLogin()
{
// some function logic
}
googleLogin()
{
// some function logic
}
<button
width="70%"
height="40"
(click)="onLogin()"
class="login-submit"
row="2">
Login
</button>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/462536.html
