小编Pro*_*fer的帖子

在 mui datepicker 6 中将 dayOfWeek 设置为星期一

我正在使用 Material ui Datepicker 6 版本,我想设置从星期一开始的 dayOfWeek。

import React from "react";
import { DatePicker as DatePickerDestop } from "@mui/x-date-pickers/DatePicker";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import moment, { Moment } from "moment";
import { setDefaultOptions } from "date-fns";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { enGB } from "date-fns/locale";

interface props {
  value: Moment | null;
  onChange: (newValue: Moment | null) => void;
  placeholder: string;
}

export default function DatePicker({ value, onChange, placeholder }: props) {
  // setDefaultOptions({ locale: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui angular mui-x-date-picker

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

如何使用 Koa Nodejs 创建 POST 请求

我刚刚开始使用Koa以下代码进行基本设置

const Koa = require('koa');
const app = new Koa();

// logger

var port     = process.env.PORT || 8080; // set our port

// response

app.use(async ctx => {
  console.log(ctx.query)
  ctx.body = 'Hello World';
});

app.listen(port);
console.log('Magic happens on port ' + port);
Run Code Online (Sandbox Code Playgroud)

现在,当我点击请求时,http://localhost:8080我会在 的控制台中收到该请求ctx.query

问题:如何使用koa 框架发出请求postget

编辑:我现在已经实现了 Koa-router

const Koa = require('koa');
const koaBody = require('koa-body');
const router = require('koa-router')();
const app = new Koa();
app.use(koaBody());
// logger

router.get('/users', …
Run Code Online (Sandbox Code Playgroud)

javascript node.js koa koa-router

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

不必要的转义字符:\`无用的转义

我正在使用事物url正则表达式验证,并且也已将eslint集成到项目中。

let url = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/
Run Code Online (Sandbox Code Playgroud)

但是当我编译代码时出现错误

  4:49  error  Unnecessary escape character: \`  no-useless-escape
  4:62  error  Unnecessary escape character: \.  no-useless-escape
  4:75  error  Unnecessary escape character: \$  no-useless-escape
  4:79  error  Unnecessary escape character: \(  no-useless-escape
  4:81  error  Unnecessary escape character: \)  no-useless-escape
  4:83  error  Unnecessary escape character: \*  no-useless-escape
  4:85  error  Unnecessary escape character: \+  no-useless-escape
Run Code Online (Sandbox Code Playgroud)

javascript regex reactjs eslint

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

Add hours minutes with the format hh:mm using moment

I am using moment library and from front end I am getting time in HH:mm I need to add hours and minutes to current time using moment.

Suppose I am getting 05:30 from the frontend and I need to add to the current UTC time. How can I do that using momentjs?

I tried that but didn't work

moment().add('05:30', 'HH:mm')
Run Code Online (Sandbox Code Playgroud)

javascript timezone momentjs

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

如何将字符串转换为 unicode?

我有我的一篇文字

\n\n
Japanese:  \xe3\x81\x93\xe3\x81\xaeOTP\xe3\x82\x92\xe4\xbd\xbf\xe7\x94\xa8\xe3\x81\x97\xe3\x81\xa6Quik\xe3\x83\x89\xe3\x83\xa9\xe3\x82\xa4\xe3\x83\x96\xe3\x81\xab\xe3\x83\xad\xe3\x82\xb0\xe3\x82\xa4\xe3\x83\xb3\xe3\x81\x97\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82 \xe3\x81\x93\xe3\x81\xaeOTP\xe3\x82\x92\xe8\xaa\xb0\xe3\x81\xa8\xe3\x82\x82\xe5\x85\xb1\xe6\x9c\x89\xe3\x81\x97\xe3\x81\xaa\xe3\x81\x84\xe3\x81\xa7\xe3\x81\x8f\xe3\x81\xa0\xe3\x81\x95\xe3\x81\x84\n
Run Code Online (Sandbox Code Playgroud)\n\n

我有它的unicode转换

\n\n
Unicode:  3053306e004f0054005030924f7f752830573066005100750069006b30c930e930a430d6306b30ed30b030a430f33057307e3059300200203053306e004f0054005030928ab030683082517167093057306a30443067304f306030553044\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我用一些在线工具完成的。现在我需要使用nodejs做同样的事情。

\n\n

所以我的问题是 Unicode 类型是什么?如何将日语文本转换为 unicode?

\n

javascript unicode unicode-string node.js

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

如何使用值数组突出显示段落中的文本?

我有值数组

const tags = ['Hello', 'moment', 'somewhere'];
Run Code Online (Sandbox Code Playgroud)

以及我的反应组件中显示的段落

const paras = [{
  text: 'Hello, tina. Thank you for all waiting. Hello?'
}, {
  text: 'When can I go? Okay. One moment. Let me just'
}, {
  text: 'if I can help you somewhere, if you are interested'
}]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我想用标签元素突出显示段落单词。并且只需要在突出显示的单词之前和之后几个单词,就像在第一句话中我只需要显示一样

 *One **moment**. Let *
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

我尝试过的:

getHighlightedText(text, highlight) {
    // Split text on highlight term, include term itself into parts, ignore case
    const parts = text.split(new RegExp(`(${highlight})`, 'gi'));
    return <span>{parts.map(part => …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

如何在react render函数中异步等待?

我对async await后端非常熟悉nodejs。但是我遇到了一种情况,我必须在前端使用它。

我正在获得对象的数组,并且在那些对象中我得到lat lng了位置。现在,react-geocode我可以获取单个地名,lat lng但是我想在map函数中使用该名称来获取地名。因此,正如我们所知道的那样,async我必须async await在那边使用。

这是代码

import Geocode from "react-geocode";
render = async() => {
  const {
    phase,
    getCompanyUserRidesData
  } = this.props   

  return (
    <div>
       <tbody>                   
        await Promise.all(_.get(this.props, 'getCompanyUserRidesData', []).map(async(userRides,index) => {
          const address = await Geocode.fromLatLng(22.685131,75.873468)
          console.log(address.results[0].formatted_address)                         
         return ( 
          <tr key={index}>
            <td>
            {address.results[0].formatted_address}
            </td>
            <td>Goa</td>
            <td>asdsad</td>
            <td>{_.get(userRides,'driverId.email', '')}</td>
            <td>{_.get(userRides,'driverId.mobile', '')}</td>
          </tr>
        )
        }))
      </tbody>
    </div>
  )
}
Run Code Online (Sandbox Code Playgroud)

但是,当我在此处将map函数与async一起使用时,它不会返回任何内容。谁能帮我解决我的问题?

谢谢!!!

javascript asynchronous promise async-await reactjs

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