问题:
按钮的 html 代码如下:
<button _ngcontent-c7="" class="cnb-button ng-star-inserted">保存草稿</button>
在 macOS 的 Safari 中第一次点击总是无任何反应,第二次点击就能正常提交,Chrome 下没这个问题,请问如何解决?
回答1:
后来 Safari 的某次更新修复了这个问题,前提是 button
需要加上 type="submit"
回答2:
虽然我也不是很清楚……
但是在网上发现了类似的问题,希望可以有些帮助。
问题:Modal window in AngularJS does not open on first click
回答内容:
The issue does appear to be due to the separate file specified in the templateUrl not yet having been downloaded when the first click happens and I have now been able to work out a solution by adding the following line into the index.html file:
<div ng-include="'mymodalcontent.html'"></div>
This directive adds a reference to the file which loads the templateUrl so that when the button is clicked the first time the modal window will appear as expected.
Please note the value in the ng-include attribute has to have single quotes in order to work as detailed in the documentation for the ng-include directive. This detail is mentioned in the section named arguments and advises:
If the source is a string constant, make sure you wrap it in quotes
I have updated the plunkr code to include the fix.
The only downside to this is the original purpose behind moving the modal window contents into a separate file was to only download the contents if the user clicked the button thus saving bandwidth for users accessing the site on a mobile device.
原帖地址:https://stackoverflow.com/questions/22245107/modal-window-in-angularjs-does-not-open-on-first-click
回答3:
你这也没有点击事件啊?
回答4:
https://github.com/angular/material2/issues/1847
可能是版本的问题
回答5:
刚过这个坑 应该是bug 我升级在angular 7就没有这个问题