小编Miz*_*lul的帖子

如何使用 JavaScript 解析和迭代 Excel 工作表文件中的所有行

我正在尝试解析和读取 Excel 工作表中的每个单元格;看来我正在解析文件,但我无法遍历每个单元格并显示它们。

我正在使用以下代码:

    var workbook = XLSX.read('datasets/persons.xlsx', { type: 'binary' });
    var sheet_name_list = workbook.SheetNames;


    // console.log(sheet_name_list);
    sheet_name_list.forEach(function (y) { /* iterate through sheets */
      //Convert the cell value to Json
      console.log(y);
      var roa = XLSX.utils.sheet_to_json(workbook.Sheets[y]);
      console.log(roa);
      if (roa.length > 0) {
        result = roa;
      }
  });
Run Code Online (Sandbox Code Playgroud)

当我尝试打印时,我得到一个空数组console.log(roa),知道我应该如何迭代文件中的每个单元格吗?

javascript sheetjs

8
推荐指数
1
解决办法
1万
查看次数

31.0.0不是有效的SDK版本。选项是26.0.0未版本化

将expo版本更新为31.0.0后,我无法再运行我的应用程序。我需要此升级才能提供iOS 12版本的支持。尝试构建Android应用后,您将无法再使用它。

我的package.json如下所示:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.13.1",
    "jest-expo": "^31.0.0",
    "react-test-renderer": "16.3.0-alpha.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "expo": "^31.0.4",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
    "react-native-image-slider": "^2.0.3",
    "react-native-onesignal": "^3.1.4",
    "react-native-progress": "^3.4.0",
    "react-native-render-html": "^3.9.3",
    "react-navigation": "^1.5.11"
  }
}
Run Code Online (Sandbox Code Playgroud)

app.json看起来像:

{
  "expo": {
    "sdkVersion": "31.0.0",
    "name": "myapp",
    "slug": "myapp",
    "version": "0.1.1",
    "isDetached": true,
    "detach": …
Run Code Online (Sandbox Code Playgroud)

java android android-studio react-native-android android-studio-3.0

8
推荐指数
2
解决办法
6572
查看次数

如何查询和过滤Firebase实时数据库

我想从用户输入名字和姓氏的数据库中获取所有人员。

到目前为止,这是我的代码:

admin.database().ref('persons').orderByChild('Firstname').equalTo(firstName).limitToLast(1).once("value").then(function(snapshot) {
}
Run Code Online (Sandbox Code Playgroud)

这段代码只能过滤名字,但是我找不到任何为姓添加其他Where子句的方法。我试图添加另一个orderBy,但它似乎不起作用。实时数据库是否必须很难进行简单的查询?

javascript node.js firebase firebase-realtime-database

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

如何使用 Javascript ajax 调用在 DialogFlow v2 上进行 http 调用

我在 DialogFlow 的官方网站上使用 Node.js 找到了这个示例,它运行良好,但我不知道如何将其集成到我的 Web 应用程序中。

我可以将它集成到我的其他 javascript jquery 代码中吗?在这里我需要运行 node index.js 但如果我与我的代码集成,我还需要这样做吗?

const projectId = 'xxx'; //https://dialogflow.com/docs/agents#settings
const sessionId = 'xxxxx';
const query = 'Hello';
const languageCode = 'en-US';

// Instantiate a DialogFlow client.
const dialogflow = require('dialogflow');
const sessionClient = new dialogflow.SessionsClient();

// Define session path
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
console.log(sessionPath);
// The text query request.
const request = {
  session: sessionPath,
  queryInput: {
    text: {
      text: query,
      languageCode: languageCode,
    },
  },
};

// Send request …
Run Code Online (Sandbox Code Playgroud)

javascript google-cloud-datastore google-cloud-platform dialogflow-es

6
推荐指数
1
解决办法
7785
查看次数

为什么我没有在打字稿中收到有关 StrictNullChecks 的警告

我在打字稿中有以下代码:

interface Member {
    name: string,
    age?: number
}

class Person implements Member {
    name: string;
    constructor(name: string ){
        this.name=name;
    }
}

function bar(person: Member) {
    return "Hello, " + person.name + " " + person.age;
}

let person = new Person("John");
console.log(bar(person));
Run Code Online (Sandbox Code Playgroud)

当我声明 person.age 时,我应该在 bar 函数中收到Object is possible 'undefined'警告,因为不是每个成员都可以有年龄。

我的打字稿配置如下所示:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "strictNullChecks": true,
    "outDir": "./built"
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

知道为什么这对我不起作用吗?我正在使用 WebStorm 编辑器!

javascript webstorm typescript

6
推荐指数
2
解决办法
5448
查看次数

使用React Native App的Android Studio构建错误

我一直在尝试使用expo工具xde使用react native创建一个应用程序,然后使用exp detach分离它,当我在Android Studio中打开时,在构建时会遇到很多错误:

Using incompatible plugins for the annotation processing

Configuration 'compile' is obsolete and has been replaced with
'implementation' and 'api'. It will be removed at the end of 2018.
For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html


The specified Android SDK Build Tools version (23.0.1) is ignored,
as it is below the minimum supported version (27.0.3) for Android
Gradle Plugin 3.1.1. Android SDK Build Tools 27.0.3 will be used. To
suppress this warning, remove "buildToolsVersion '23.0.1'" from your
build.gradle file, …
Run Code Online (Sandbox Code Playgroud)

build.gradle android-gradle-plugin react-native react-native-android android-studio-3.1

5
推荐指数
1
解决办法
3464
查看次数

如何将上下文参数发送到 webhook/fulfilments DialogFlow v2

我正在从此链接阅读官方文档:https : //cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2beta1/QueryParameters但我无法使用以下代码将上下文参数传递到我的请求中:

  var query = req.body.query;
    const request = {
      session: sessionPath,
      queryInput: {
        text: {
          text: query,
          languageCode: 'en-US',
        },
      },
      queryParameters: {
        contexts: ['Question-followup']
      },
    };

    // Send request and log result
    sessionClient
      .detectIntent(request)
      .then(responses => {
        const result = responses[0].queryResult;
        console.log(result);
        res.json(result);   
        if (result.intent) {
          console.log(`  Intent: ${result.intent.displayName}`);
        } else {
          console.log(`  No intent matchede.`);
        }
      })
      .catch(err => {
        console.error('ERROR:', err);
      });
Run Code Online (Sandbox Code Playgroud)

在文档中它说我应该有类似的东西:

"contexts": [
    {
      object(Context)
    }
  ],
Run Code Online (Sandbox Code Playgroud)

我想要这个的原因是有时 DialogFlow 无法检测到意图,所以我认为通过将上下文传递到参数中将有助于 dialogflow …

javascript google-api node.js google-cloud-platform dialogflow-es

5
推荐指数
1
解决办法
3678
查看次数

如何在Reactjs Web应用程序中使用媒体打印

我想在打印预览发生时隐藏div,但是我发现在React中几乎不可能做到这一点。

<div className="contacts"></div>
Run Code Online (Sandbox Code Playgroud)

有没有可能添加纯CSS或在打印预览时React Stylesheet支持@media print并隐藏带有类名联系人的元素。

我正在阅读这篇文章https://blog.logrocket.com/the-best-react-inline-style-libraries-comparing-radium-aphrodite-emotion-849ef148c473,但这似乎对我做得不好的事情来说工作太多了在CSS中只需几秒钟。

知道如何在Reactjs中实现这种目标吗?

html javascript css css3 reactjs

5
推荐指数
2
解决办法
2306
查看次数

如何在三次回退后使用 Dialogflow 抛出自定义消息

我正在使用 Dialogflow 开发聊天机器人,当聊天机器人连续三次无法理解用户输入时,我想向用户发送一条消息,第四次以自定义消息(不是选项之一)进行响应在 dialogflow 接口上声明)

我的一个想法是在输入未知操作中创建一个计数器,如下所示:

var counter = 1;
// The default fallback intent has been matched, try to recover (https://dialogflow.com/docs/intents#fallback_intents)
'input.unknown': () => {
    // Use the Actions on Google lib to respond to Google requests; for other requests use JSON
    if (requestSource === googleAssistantRequest) {
        sendGoogleResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
    } else {
        if (counter == 3) {
            counter = 1;
            sendResponse('Custom message');
        } else {
            counter++;
            sendResponse('I\'m …
Run Code Online (Sandbox Code Playgroud)

javascript bots chatbot google-cloud-functions dialogflow-es

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

无法从Dialogflow内联编辑器中发出http请求

我正在制作一个聊天机器人,我需要采取某些行动来提出一些http请求,但由于某种原因看起来账单的账单问题我不能进行http调用.

这是代码:

    const actionHandlers = {
         'get.contact': () => {
            var options = {
              host: 'xxx.herokuapp.com',
              port: 443,
              method: 'GET',
              path: '/',
            headers: {
                "Accept": "application/json",
                "Content-Type": "application/json"
              },
            };

            http.get('http://xxx.herokuapp.com/', function(res){
                console.log(res);
            });

          if (requestSource === googleAssistantRequest) {
            sendGoogleResponse('Hello, Welcome to my Dialogflow agent!'); // Send simple response to user
          } else {
            sendResponse('here should come the result from http request response.'); // Send simple response to user
          }
        } 
    }
Run Code Online (Sandbox Code Playgroud)

在firebase日志中,我收到以下消息:未配置结算帐户.无法访问外部网络,配额受到严格限制.

我还有什么其他选择可以在不启用结算的情况下拨打一些外部http电话?有什么工作吗?

另外一个问题,我可以在内联编辑器中使用任何excel解析器吗?我想解析一些excel文件,如果是这样,我在哪里存储excel表文件?所以我的想法是我想从Dialogflow内联编辑器中的Excel工作表中查询.

javascript chatbot firebase google-cloud-functions dialogflow-es

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