繁体   English   中英

Flutter:webview 内的链接打开到内置浏览器而不是 webview

[英]Flutter: Link inside the webview opens to built in browser instead of the webview

我已经使用flutter创建了一个webview,我现在想向我创建的webview显示一个本地webapp。

import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:webview_flutter/webview_flutter.dart';

class EnableJavacriptWebView extends StatefulWidget {
  @override
  EnableJavacriptWebViewState createState() {
    return new EnableJavacriptWebViewState();
  }
}

class EnableJavacriptWebViewState extends State<EnableJavacriptWebView> {
  bool _isJSEnabled = true;

  _onChanged() {
    setState(() {
      _isJSEnabled = !_isJSEnabled;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("TEST")),
      body: Stack(
        children: [
          WebView(
            initialUrl: 'https://flutter.io/',
            javascriptMode: _isJSEnabled
                ? JavascriptMode.unrestricted
                : JavascriptMode.disabled,
          ),
        ],
      ),
    );
  }
}

但发生的情况是,当我加载应用程序(webview)时,它会打开内置浏览器而不是内部 webview 应用程序。

webview_flutter中使用了旧版本的flutter_webview_pluginpubspec.yaml应该使用最新版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM