小编Sed*_*rei的帖子

“{”之后不应有空格(babel/object-curly-spacing)

我正在使用shift + alt + f它来对代码进行排序vscode,但为什么我会收到此错误:?

错误:

[eslint] There should be no space after '{' (babel/object-curly-spacing)
Run Code Online (Sandbox Code Playgroud)

代码:

 User.findOne({ _id: temp }, (obj) => {
Run Code Online (Sandbox Code Playgroud)

删除 _id 之前和 temp 之后的空格后,我没有任何错误,但我应该如何修复 vscode 中的自动排列?

javascript eslint visual-studio-code

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

Firebase检测用户是否存在

如何Signup通过反应原生来检查按钮中的Firebase auth中是否存在用户?

这是我的登录页面代码:

export default class Login extends Component {
    constructor(props) {
        super(props)
        this.state = {
            email: '',
            password: '',
            response: ''
        }
        this.signUp = this.signUp.bind(this)
        this.login = this.login.bind(this)
    }

    async signUp() {
        try {
            await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
            this.setState({
                response: 'Account Created!'
            })
            setTimeout(() => {
                this.props.navigator.push({
                    id: 'App'
                })
            }, 500)
        } catch (error) {
            this.setState({
                response: error.toString()
            })
        }
    }
    async login() {
        try {
            await firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
            this.setState({
                response: 'user login in'
            })

            setTimeout(() => …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native firebase-authentication

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

在向下滚动时反应本机淡入淡出右/左视图

我在中有3 ViewScrollView,如何View在Scroll Down上向右或向左淡入淡出?

<ScrollView >
  <View>
    <Text>Fade Right View 1</Text>
  </View>

  <View>
    <Text>Fade Right View 2</Text>
  </View>

  <View>
    <Text>Fade Right View 3</Text>
  </View>
</ScrollView >
Run Code Online (Sandbox Code Playgroud)

像这样:元素淡入滚动(https://codepen.io/annalarson/pen/GesqK

reactjs react-native

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

通过node.js电报Bot sendPhoto

我正在使用此功能通过node.js发送照片,但这不起作用。 telegram-bot-api https://www.npmjs.com/package/telegram-bot-api

var telegram = require('telegram-bot-api');

var api = new telegram({
    token: '<PUT YOUR TOKEN HERE>',
});

api.sendPhoto({
    chat_id: <YOUR CHAT ID>,
    caption: 'This is my test image',

    // you can also send file_id here as string (as described in telegram bot api documentation)
    photo: '/path/to/file/test.jpg'
})
.then(function(data)
{
    console.log(util.inspect(data, false, null));
});
Run Code Online (Sandbox Code Playgroud)

但是我有这个错误

 fn = function () { throw arg; };
                           ^
StatusCodeError: 403 - [object Object]
Run Code Online (Sandbox Code Playgroud)

javascript java node.js telegram telegram-bot

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

Telegeram Bot中`msg.chat.id`和`msg.from.id`的区别是什么?

Telegeram Bot msg.chat.id和之间的区别是什么msg.from.id显然,两者都是相同的并且返回用户ID.

bot.sendMessage(msg.chat.id, 'Hi', opts)
Run Code Online (Sandbox Code Playgroud)

bot.sendMessage(msg.from.id, 'Hi', opts)
Run Code Online (Sandbox Code Playgroud)

telegram-bot node-telegram-bot-api

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

通过电报机器人获取用户位置经纬度

如何通过电报机器人获取用户位置纬度和经度?

模块:链接

代码:

bot.onText(/getLocation/, (msg) => {
  const opts = {
    reply_markup: JSON.stringify({
      keyboard: [
        [{text: 'Location', request_location: true}],
        [{text: 'Contact', request_contact: true}],
      ],
      resize_keyboard: true,
      one_time_keyboard: true,
    }),
  };
  bot.sendMessage(msg.chat.id, 'Contact and Location request', opts);
});
Run Code Online (Sandbox Code Playgroud)

javascript node.js telegram-bot node-telegram-bot-api

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

无法暂停播放本机视频

我想播放音频文件,但是它正在自动播放,我不能暂停播放。

我该如何解决?我的代码
开始时必须暂停

import Video from 'react-native-video';

export default class Android extends Component {
  constructor(props) {
    super(props)
    this.state = {
      paused: true,
    }
  }

  video: Video;

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
        <Video
          ref={(ref: Video) => { this.video = ref }}
          source={{ uri: "http://s3.picofile.com/d/7376893331/8b7bc5b4-4b5e-47c4-96dd-b0c13fd18157/Sara_Diba_Delbare_Man.mp3", mainVer: 1, patchVer: 0 }}
          paused={this.state.paused} …
Run Code Online (Sandbox Code Playgroud)

react-native

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

通过PHP解决JSON中的换行符

我解析此JSON数组和我想利用type对象,并提出,在新列type2,这是一个排的我JSON行,我获取的foreach(提供)由于新线的JSON无效参数在某些行。我该如何解决?

这不是奥奇

[{"id":"26","answer":[{"option":"4","text":"Hello
"}],"type":"3"}]
Run Code Online (Sandbox Code Playgroud)

这个是奥基

[{"id":"26","answer":[{"option":"4","text":"Hello"}],"type":"3"}]
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

<?php
$con=mysqli_connect("localhost","root","","array");
mysqli_set_charset($con,"utf8");

// Check connection
if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

$sql="SELECT `survey_answers`,us_id FROM `user_survey_start`";
if ($result=mysqli_query($con,$sql)){
    while ($row = mysqli_fetch_row($result)){
        $json = $row[0];
        if(!is_null($json)){
            $jason_array = json_decode($json,true);
            // type2
            $type = array();
            foreach ($jason_array as $data) {
                if (array_key_exists('type', $data)) {
                    // Now we will only use it if it actually exists
                    $type[] = $data['type'];
                }
            }         
            // lets …
Run Code Online (Sandbox Code Playgroud)

php mysql json

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

Telegram Bot 不是构造函数 • TypeScript

为什么我有这个错误:
TypeError: node_telegram_bot_api_1.default is not a constructor

这是我的 TypeScript 代码:

import * as dotenv from 'dotenv';
dotenv.config({ path: __dirname + '/.env'})
console.log('Hello TypeScript')
import TelegramBot from 'node-telegram-bot-api';    
const bot = new TelegramBot(process.env.BOT_TOKEN, {polling: true});
Run Code Online (Sandbox Code Playgroud)

这是我编译后的输出代码:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv = require("dotenv");
dotenv.config({ path: __dirname + '/.env' });
console.log('Hello TypeScript');
const node_telegram_bot_api_1 = require("node-telegram-bot-api");
const bot = new node_telegram_bot_api_1.default(process.env.BOT_TOKEN, { polling: true });
Run Code Online (Sandbox Code Playgroud)

照片

javascript typescript telegram-bot

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

错误:应为“/* Begin”、“/* End”、“\””或 [A-Za-z0-9_.],但找到了“&lt;”

React Native 中如何解决这个问题?我使用此命令:
react-native link用于链接react-native-vector-icons

我的错误:

rnpm-install ERR! Something went wrong while linking. Error: Expected "/* Begin ", "/* End ", "\"", or [A-Za-z0-9_.] but "<" found.
Please file an issue here: https://github.com/facebook/react-native/issues

Expected "/* Begin ", "/* End ", "\"", or [A-Za-z0-9_.] but "<" found.
Run Code Online (Sandbox Code Playgroud)

javascript react-native

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

通过crypto-js的base64编码器

我想将数字编码为字符。

  • 如何在输出中编码为base64?

码:

const CryptoJS = require('crypto-js');

function msg() {
  return '7543275'; // I want to encrypt this number to character
}

const msgLocal = msg();

// Encrypt
const ciphertext = CryptoJS.AES.encrypt(msgLocal, 'password');

// Decrypt
const bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'password');
const plaintext = bytes.toString(CryptoJS.enc.Utf8);

console.log(plaintext);
Run Code Online (Sandbox Code Playgroud)

javascript encryption base64 cryptojs

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