(点击)只在Chrome中工作而不在其他人工作 [英] (click) only working in Chrome not working in others
问题描述
我创建了一个Angular web应用程序,
link: - http://mohitkyadav.github.io/algos-ngular
现在,当我在Chrome中浏览此网站时,一切正常正如预期的那样,但在Edge和Firefox等其他浏览器中,当我在应用程序中单击side-nav中的元素时,没有任何反应,添加了一些 console.log(hi)
I找出问题所在。
在github上查看此行
$ b
https://github.com/mohitkyadav /algos-ngular/blob/master/src/app/views/content.component.html#L7
点击事件应该被触发。
(打字稿)
正如这行所写,事件应该在控制台中打印。它在Chrome和UC浏览器PC中运行良好,但在Firefox和Edge中无法使用。
当我点击side-nav中的任何项目时,代码将以日期显示在控制台中但在Firefox中,控制台是空的,没有任何反应。
请帮助我。你可以测试你的自我开放 https://mohitkyadav.github.io/algos-ngular/
并打开您的Chrome控制台和Firefox控制台,然后点击侧边导航栏项目,请给我宝贵的建议。
似乎它与角度无关。
查看 HTML5 standart $ b
内容模型:
表示内容,但不能有交互式内容后裔。
< button>
< div(click)=fetchCode()>
点击我,但我不会在Firefox中使用IE
< / div>
< / button>
单击子元素将不起作用,因为它嵌套在按钮中。
您可以将点击事件移至按钮
<按钮(点击)= fetchCode() >
< div>
这应该工作
< / div>
< / button>
或使用另一个标签代替按钮
< div class =button>
< div(click)=fetchCode()>
这也应该工作
< / div>
< / div>
另请参阅
I've created an Angular web app,
link :- http://mohitkyadav.github.io/algos-ngular
Now when I browse this site in Chrome, everything works fine as expected but in other browsers like Edge and Firefox when I click the elements in side-nav on my app nothing happens, after adding some console.log("hi")
I figured out the problem.
see this line on github
https://github.com/mohitkyadav/algos-ngular/blob/master/src/app/views/content.component.html#L7
an click event should be fired.
(typescript)
https://github.com/mohitkyadav/algos-ngular/blob/master/src/app/components/content.component.ts#L34
As written in this line the event should print in the console. It's working fine in Chrome and UC browser PC but not working in Firefox and Edge.
When I click any item from side-nav, the code logs it in console in chrome but in Firefox the console is empty, nothing happens.
Please help me. You can test it your self open https://mohitkyadav.github.io/algos-ngular/
and also open your Chrome console and Firefox console and click side-nav items, please give me your valuable suggestions.
Seems it has nothing to do with angular.
Look at button definition in HTML5 standart
Content model: Phrasing content, but there must be no interactive content descendant.
<button>
<div (click)="fetchCode()">
Click me but i won't work in Firefox in IE
</div>
</button>
Clicking at the children elements won't work because it is nested inside a button.
You can either move click event to button
<button (click)="fetchCode()">
<div>
This should work
</div>
</button>
or use another tag instead of button
<div class="button" >
<div (click)="fetchCode()">
This also should work
</div>
</div>
See also
- Missing click event for <span> inside <button> element on firefox
- Element inside button does not fire click event in Firefox
这篇关于(点击)只在Chrome中工作而不在其他人工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!