gpt4 book ai didi

javascript - _co.open 不是函数 :run method based on condition

转载 作者:行者123 更新时间:2023-11-30 20:54:39 26 4
gpt4 key购买 nike

我有一个方法,该方法应该根据条件执行,这里我在 map 上点击标记打开一个模式窗口。

    if(this.showMobile){
open(content) {
this.modalService.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
}

在 if 语句“TypeError: _co.open is not a function”中包含该 open 方法后出现此错误。想根据条件打开模态窗口。

<div id="dvMap"  (click)="open(content)"  style="width:900px;height:600px;"></div>

最佳答案

将条件置于内部打开:

open(content) {
if(this.showMobile) {
this.modalService.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
}

关于javascript - _co.open 不是函数 :run method based on condition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47807822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com