仅在 ios 中,我在尝试从如下状态连接 URL 后遇到此问题:
componentDidMount(){
let unionUrl = this.props.datos.brand + " " + this.props.datos.name
this.setState({
busqueda: unionUrl
})
}
Expo.WebBrowser.openBrowserAsync("https://www.example.com/search?query=" + this.state.busqueda)
抛出的错误是这样的
,
似乎它正在注入(inject)一个数组,而不是一个字符串(?)
我之前在 react 中尝试过这种方法并且效果很好
最佳答案
我通过包围这样的 Prop 来解决它:
const url = "http://example.com/search?query=" +`${this.props.datos.brand} ${this.props.datos.name}`
const urlOk = url.split(' ').join('+').toString()
await WebBrowser.openBrowserAsync(urlOk)
这个解决方案似乎适用于 android 和 ios,但有点令人失望,因为我的语言的键盘布局中不存在“`”字符。
关于ios - 异常 : "The specified URL has an unsupported scheme. Only http and https URLs are supported",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51960709/