(点击)仅适用于在其他人中使用的Chrome浏览器

时间:2017-07-23 10:57:04

标签: angular google-chrome typescript firefox microsoft-edge

我已经创建了一个Angular网络应用

链接: - http://mohitkyadav.github.io/algos-ngular

现在,当我在Chrome中浏览此网站时,一切正常,但在其他浏览器(如Edge和Firefox)中,当我点击我的应用程序中的侧导航中的元素时,没有任何反应,添加了一些console.log("hi")之后我认为解决问题。

在github上看到这一行

https://github.com/mohitkyadav/algos-ngular/blob/master/src/app/views/content.component.html#L7

应该触发点击事件。

(的打字稿

https://github.com/mohitkyadav/algos-ngular/blob/master/src/app/components/content.component.ts#L34

如此行所写,事件应在控制台中打印。它在Chrome和UC浏览器PC上运行良好,但在Firefox和Edge中无法正常工作。

当我从侧面导航中点击任何项目时,代码会在控制台中以chrome身份登录,但在Firefox中,控制台为空,没有任何反应。

请帮帮我。您可以自行测试https://mohitkyadav.github.io/algos-ngular/

并打开Chrome控制台和Firefox控制台并点击侧面导航项,请向我提供宝贵的建议。

1 个答案:

答案 0 :(得分:6)

似乎与角度无关。

查看HTML5 standart

中的按钮定义
  

内容模型:       短语内容,但必须没有互动内容后代。

<button>
  <div (click)="fetchCode()">
    Click me but i won't work in Firefox in IE
  </div>
</button>

点击子元素不会起作用,因为它嵌套在按钮内。

您可以将点击事件移至按钮

<button (click)="fetchCode()">
  <div>
    This should work
  </div>
</button>

或使用其他标签代替按钮

<div class="button" >
  <div (click)="fetchCode()">
    This also should work
  </div>
</div>

另见