openwebf / webf

Build flutter apps with HTML/CSS and JavaScript.
https://openwebf.com/
Apache License 2.0
1.66k stars 121 forks source link

After the jump of tag a, the channels of dart and js are no longer useful #652

Closed chengming111 closed 3 weeks ago

chengming111 commented 3 months ago

Affected version

0.16.2

Flutter versions

3.22.3

No same issues found.

Steps to Reproduce

After clicking the Submit button on the homepage, the loading animation can be displayed normally, but after the page jumps, an error message appears when clicking the Submit button.

Code example

  1. There is a function 'submitMap' in plugin submitMap(jsonString) { return webf.methodChannel.invokeMethod('submitMap', jsonString); }

  2. in dart case 'submitMap': showLoading(); // Simulate processing, hide the loading after 2 seconds await Future.delayed(Duration(seconds: 2)); hiddenLoading(); onSubmit(args[0]); return null;

  3. In html and js, I have

    const submit = document.getElementById('submit'); submit.addEventListener('click', async(e) => { ...... await window.form.submitMap(jsonString); });

Expected results

loading animation

Actual results

截屏2024-08-22 16 16 09

andycall commented 3 months ago

let me check it out

chengming111 commented 3 months ago

非常感谢您的回复。请问您查看了吗,可以正常使用吗

andycall commented 3 months ago

近期都在处理商业技术支持(24小时内响应),社区支持只能在空闲时间搞一下,平均响应时间在 1-2 周。

最近客户需求有点多,还请耐心等待

andycall commented 2 months ago

@chengming111

window.form

这个是在哪里定义的,你在哪里注入了一个脚本来实现了这个函数?

chengming111 commented 2 months ago

您好,我在assets/plugin/base_plugin.js 中定义的

class Form {
    constructor() {};

    // 用户点击提交按钮后,将数据传回dart
    submitMap(jsonString) {
        return webf.methodChannel.invokeMethod('submitMap', jsonString);
    }

}
window.form = new Form();
andycall commented 2 months ago

通过 script 标签引入的吗

chengming111 commented 2 months ago

是的

andycall commented 2 months ago

@chengming111 我尝试按你的步骤写了个 demo,但是依然没有复现,具体有关跳转的操作没有提供相应的代码。

https://github.com/andycall/webf-issue-demo-652

需要提供可复现的 demo