首页 新闻 会员 周边 捐助

Angular 应用在 Safari 中第一次点击按钮总是无反应

0
悬赏园豆:100 [已解决问题] 解决于 2019-05-14 15:28

按钮的 html 代码如下:

<button _ngcontent-c7="" class="cnb-button ng-star-inserted">保存草稿</button>

在 macOS 的 Safari 中第一次点击总是无任何反应,第二次点击就能正常提交,Chrome 下没这个问题,请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:30757
提问于:2018-10-22 18:11
< >
分享
最佳答案
0

后来 Safari 的某次更新修复了这个问题,前提是 button 需要加上 type="submit"

dudu | 高人七级 |园豆:30757 | 2019-05-14 15:27
其他回答(4)
0

虽然我也不是很清楚……
但是在网上发现了类似的问题,希望可以有些帮助。
问题: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

收获园豆:30
芽衣 | 园豆:384 (菜鸟二级) | 2018-10-23 09:01
0

你这也没有点击事件啊?

收获园豆:10
博学多思 | 园豆:76 (初学一级) | 2018-10-23 11:13
0
收获园豆:30
放逐人 | 园豆:694 (小虾三级) | 2018-10-25 18:25
0

刚过这个坑 应该是bug    我升级在angular 7就没有这个问题

收获园豆:30
SpeakHero | 园豆:31 (初学一级) | 2018-10-29 19:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册