小编Kap*_*dav的帖子

injectJavaScript在Webview中不起作用本机

我无法将这个简单的js代码注入到反应原生的webview中.

我也提到了这个链接,但这里没有提供解决方案.

然后我发现这个适用于html道具但不适用于uri.

import React, { Component } from 'react';
import { Platform,
  StyleSheet,
  Text,
  View,
  WebView
} from 'react-native';

export default class App extends Component<{}> {

  injectjs(){

    let jsCode = 'alert(hello)';
    return jsCode;
  }

  render() {
    return <WebView 
    javaScriptEnabled={true}
    injectedJavaScript={this.injectjs()} 
    source={{uri:"https://www.google.com"}} style={{ marginTop: 20 }} />;
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript android webview react-native

7
推荐指数
4
解决办法
2万
查看次数

无法访问Google日历api的googleapis auth.OAuth2

下面的代码是从Google日历Api部分的node.js快速入门中粘贴的。此代码无法从google API的auth中访问。我复制了以下错误。要查看完整的代码,您可以访问此链接。谢谢。

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
Run Code Online (Sandbox Code Playgroud)

错误看起来像这样:

const OAuth2Client = google.auth.OAuth2; ^
TypeError:无法读取未定义的属性“ OAuth2”

google-calendar-api google-api node.js node-modules

2
推荐指数
1
解决办法
472
查看次数