【问题标题】:how to open a link in browser - Vue Native如何在浏览器中打开链接 - Vue Native
【发布时间】:2021-01-12 21:35:30
【问题描述】:

几乎没有这方面的信息。我正在尝试使用 react-native 中的 Linking 组件,但是关于使用 react-native 组件的信息很少,我不确定我是否正确使用它...

这是我在模板中的内容:

<nb-button :on-press="loadInBrowser">
    <nb-text class="source"> Test hyperlink </nb-text>
</nb-button>

这里是脚本:

import Linking from "react-native";
export default {
    components: {
        Linking
    },
    //data(),
    methods: {
        loadInBrowser: function () {
          Linking.openURL("https://www.google.com");
        },
    },
}

但不起作用,我收到此错误:

"TypeError: _reactNative.default.openURL is not a function. (In '_reactNative.default.openURL("https://www.google.com")', '_reactNative.default.openURL' is undefined)

【问题讨论】:

    标签: reactjs react-native vue.js url native


    【解决方案1】:

    这对我有用:

    Linking.Linking.openURL("https://www.google.com");
    

    【讨论】:

    • edit您的回答并解释此代码的作用,以获得更多说明。阅读How to Answer 并使用tour 了解该网站的运作方式。
    猜你喜欢
    • 2016-06-02
    • 2012-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多