请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册
搜索

华为web组件无法响应事件

2
回复
1507
查看
[复制链接]

16

主题

112

帖子

920

积分

 楼主| 2018-6-9 14:49:52 显示全部楼层 |阅读模式
本帖最后由 jy 于 2018-6-11 12:38 编辑 在华为快应用加载器中,web组件无法触发 titlereceive、pagefinish等事件,快应用官方调试器没有这个问题 下面是代码:
  1. <template>
  2. <!-- template里只能有一个根节点 -->
  3. <div class="container">
  4. <text class="title">
  5. Hello {{title}}
  6. </text>
  7. <input type="button" value="网页" onclick="onWebShow()"></input>
  8. <web id="web" ontitlereceive="onWebTitChange" onpagefinish="onWebLoaded" src="{{webUrl}}" style="display:{{webShow ? 'flex':'none'}};"></web>
  9. </div>
  10. </template>
  11. <style>
  12. web{position:fixed;left:0;top:0;right:0;bottom:0;display:none;width:100%;height:100%;}
  13. .container {
  14. flex-direction: column;
  15. justify-content: center;
  16. align-content: center;
  17. align-items: center;
  18. }
  19. .title {
  20. font-size: 100px;
  21. }
  22. </style>
  23. <script>
  24. import prompt from '@system.prompt'
  25. import shortcut from '@system.shortcut'
  26. import webview from '@system.webview'
  27. module.exports = {
  28. data: {
  29. title: 'World',
  30. webUrl:'',
  31. webShow:false
  32. },
  33. onWebShow(){
  34. var url = 'http://www.baidu.com';
  35. var url1 = 'https://quickapp.cn';
  36. if(this.webUrl && this.webUrl == url){url = url1}
  37. if(url != this.webUrl){
  38. this.webShow = true;
  39. this.webUrl = url;
  40. }else{
  41. this.webShow = true;
  42. }
  43. return;
  44. },
  45. onWebLoaded(){
  46. prompt.showDialog({
  47. title: '提示',
  48. message: "网页加载完成",
  49. buttons: [
  50. {
  51. text: '确定',
  52. color: '#33dd44'
  53. }
  54. ]
  55. });
  56. },
  57. onWebTitChange(tobj){
  58. prompt.showDialog({
  59. title: '提示',
  60. message: tobj.title,
  61. buttons: [
  62. {
  63. text: '确定',
  64. color: '#33dd44'
  65. }
  66. ]
  67. });
  68. },
  69. onInit() {
  70. this.$page.setTitleBar({
  71. text: 'menu',
  72. textColor: '#ffffff',
  73. backgroundColor: '#007DFF',
  74. backgroundOpacity: 0.5,
  75. menu: true
  76. })
  77. },
  78. onMenuPress() {
  79. var that = this;
  80. prompt.showContextMenu({
  81. itemList: ['关闭网页','添加到桌面'],
  82. success: function (data) {
  83. if(data.index == 0){
  84. that.webShow = false;
  85. }else if(data.index == 1){
  86. shortcut.install({
  87. success: function () {
  88. // 使用应用加载器时,请先在设置中打开应用加载器的桌面快捷方式
  89. prompt.showToast({
  90. message: "桌面图标创建成功"
  91. })
  92. },
  93. fail: function (erromsg, errocode) {
  94. prompt.showToast({message: "创建失败" + errocode + ': ' + erromsg})
  95. },
  96. complete: function () {
  97. console.log('shortcut complete');
  98. }
  99. })
  100. }
  101. },
  102. fail: function (data, code) {
  103. console.log("handling fail, code=" + code);
  104. },
  105. cancel: function (data) {
  106. console.log("handling cancel");
  107. },
  108. complete: function () {
  109. console.log("handling complete");
  110. },
  111. })
  112. }
  113. }
  114. </script>
复制代码
华为渲染器效果: http://u2988804.ctcontents.com/drfiles/2988804/294379386/hw.mp4 快应用官方渲染器效果: http://u2988804.ctcontents.com/d ... 379389/quickapp.mp4
回复

使用道具 举报

0

主题

40

帖子

150

积分

2018-6-10 17:47:48 显示全部楼层
我们尽快排查,另外建议加我微信junjun360422,通过微信联调验证结果。
回复

使用道具 举报

16

主题

112

帖子

920

积分

 楼主| 2018-6-12 12:16:27 显示全部楼层
华为官方人员已经找到问题了: 在华为的渲染器下,web组件的position设置为fixed时,将无法触发web的事件 华为新版渲染器将会修复该bug
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册