小编Phi*_*hil的帖子

React-Select 破坏了 CoreUi 功能

我使用的是@coreui/reactReact-select问题是,返回Select的元素scoped slotscore-ui的功能就像搜索排序

但是,如果在返回带有文本Ex 的a<label>或 a时它工作正常:<p><label>{item.status}</label>

为什么 Select 组件会破坏功能?

任何解决方法/努力都受到高度赞赏

笔记

我尝试过类似的解决方法<p hidden >{item.status}</p>,然后渲染Select组件,但它不起作用

import React from "react";
import Select from "react-select";
import { CDataTable } from "@coreui/react";

...

  <CDataTable
    bordered
    clickableRows
    fields={fields}
    hover
    items={[...employeeData]}
    itemsPerPage={10}
    itemsPerPageSelect
    loading={tableLoader}
    onRowClick={(e) => rowSelectHandler(e)}
    pagination
    size="sm"
    sorter={{ resetable: true }}
    striped
    tableFilter={{
      placeholder: "Filter",
      label: "Search:",
    }}
    scopedSlots={{
      status: (item, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-select core-ui

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

模拟 firebase 模块后模拟 firebase auth 方法的实现

我想更改内部方法的实现jest.mock,以便我可以检查我的应用程序对不同边缘情况的反应,所以我这样做了,但是打字稿不允许我模拟firebase.auth().currentUser方法...我在下面显示我的代码和错误

\n\n

应用程序.js

\n\n
import firebase from 'firebase/app'\nimport 'firebase/auth'\nimport './Init'\n\nconst App = {\ngetLoggedInUser: () => {\n    const currentUser = firebase.auth().currentUser\n    if (currentUser) {\n      return {\n        email: firebase.auth().currentUser.email,\n        userId: firebase.auth().currentUser.uid,\n        isEmailVerified: firebase.auth().currentUser.emailVerified\n      }\n    } else {\n      return undefined\n    }\n  },\n  isAuthenticated: () => {\n    return !!((App.getLoggedInUser() && App.getLoggedInUser().isEmailVerified === true))\n  },\n}\nexport default App\n
Run Code Online (Sandbox Code Playgroud)\n\n

应用程序规范

\n\n
import myAuthenticationPlugin from 'authenticationPlugin/App'\nimport firebase from 'firebase/app'\n\njest.mock('firebase/app', () => {\n  const userCredentialMock = {\n    user: {\n      sendEmailVerification: jest.fn()\n    }\n  }\n  return …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing typescript jestjs firebase-authentication

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

使用express和multer上传文件后如何下载?

我已经filesystem使用multer

我的服务器是node,客户端是react.

我在客户端下载和显示保存的文件时遇到问题 react

每当我这样做时,res.download(file)都会因为客户端拒绝连接而引发错误。

我的代码如下:

用户上传映射.js

const mongoose = require("mongoose");

const UserToUploadMapping = new mongoose.Schema({
  userId: {
      type:String,
      required:true
  },
  file: {
    type: Object,
    required: true,
  },
  date: {
    type: Date,
    default: Date.now,
  },
});

module.exports = mongoose.model("UserToUploadMapping", UserToUploadMapping);
Run Code Online (Sandbox Code Playgroud)

上传视频.js

const router = require("express").Router();
const multer = require('multer');
const UserToUploadMapping = require('../models/UserToUploadMapping')

let nameFile = ''
const storage = multer.diskStorage({
    destination:'./Videos',
    filename:(req,file,cb) => {
        console.log(file)
        nameFile = file.originalname + " …
Run Code Online (Sandbox Code Playgroud)

javascript mongoose node.js express multer

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

Firebase 向用户发送电子邮件验证

我正在使用Javascript并与我的应用程序Vue集成firebase

场景(已搭建)

  • 我有一个sign in用户登录的页面
  • 对于要在emailVerified属性中签名的用户应为 true

问题

  • 我只能在使用该firebase.auth().createUserWithEmailAndPassword(email, password)方法时发送验证电子邮件

报名方式

signup: async (email, password) => {
    const user = await firebase.auth().createUserWithEmailAndPassword(email, password)
    await user.user.sendEmailVerification()
    return `Check your email for verification mail before logging in`
  },
Run Code Online (Sandbox Code Playgroud)

所需的解决方案

  • 我从 firebase console

  • email作为参数传递或uid该方法应该向用户发送验证电子邮件,以便他们可以验证他们的电子邮件

  • 完全废弃该signup方法,因为我不再需要它来发送验证邮件

无论如何,是否可以在不登录的情况下发送验证电子邮件?

javascript firebase vue.js firebase-authentication

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

如何模拟 firebase.auth.UserCredential 笑话?

这是我当前的模拟,我想createUserWithEmailAndPassword返回firebase.auth.UserCredential,这样我就可以测试它是否在我的中被调用App.ts

应用程序规范

import myAuthenticationPlugin from 'authenticationPlugin/App'
import firebase from 'firebase/app'
jest.mock('firebase/app', () => {
  return {
    auth: jest.fn().mockReturnThis(),
    currentUser: {
      email: 'test',
      uid: '123',
      emailVerified: true
    },

    signInWithEmailAndPassword: jest.fn(),
    createUserWithEmailAndPassword:jest.fn(() => {
      return {
        user:{
          sendEmailVerification:jest.fn(),
        },
      }
    }),
    initializeApp:jest.fn()
  };
});

 describe('Test for signup (email,password)',() => {

    it('createUserWithEmailAndPassword ()',async () => {  //this works
      await myAuthenticationPlugin.signup(email, password)
      expect(firebase.auth().createUserWithEmailAndPassword).toBeCalledWith(email, password)
    })

    it('sendEmailVerification()',async ()=>{
      await myAuthenticationPlugin.signup(email, password)
      const userCredential= await firebase.auth().createUserWithEmailAndPassword(email,password)
      if(userCredential.user!=null){
      expect(userCredential.user.sendEmailVerification).toBeCalled() //this fails as …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing firebase typescript jestjs

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

Javascript如何将带有值的对象转换为键值对的对象

如何将set只有值的对象转换为键值对包含相同值的对象key

let set = new Set()
set.add(a)
set.add(example)
console.log(set)
//OUTPUT {"a", "example"}

//perform some operation to get result below ?
Run Code Online (Sandbox Code Playgroud)

{"a":"a","example":"example"}

javascript

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