如何在浏览器中打开链接-Vue Native



实际上没有关于这方面的信息。我正在尝试使用来自react native的Linking组件,但关于使用react nativecomponents的信息很少,我不确定我是否正确使用了它。。。

以下是我在模板中的内容:

<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)

这对我有效:

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

最新更新