小编Kni*_*ler的帖子

如何console.log in playwright

我想记录剧作家测试用例中的变量之一,但无法在开发人员工具控制台中加载日志,因为我正在使用 page.on() 函数

test('largest contentful paint', async ({ page }) => {
  await page.goto('http://localhost:3000/', { waitUntil: 'networkidle' });

  const largestContentfulPaint = await page.evaluate(() => {
    return new Promise((resolve) => {
      new PerformanceObserver((l) => {
        const entries = l.getEntries();
        // the last entry is the largest contentful paint
        const largestPaintEntry = entries.at(-1);
        page.on('console', () => {
          console.log('largestPaintEntry', largestPaintEntry);
        });
        // resolve(largestPaintEntry.startTime);
      }).observe({
        type: 'largest-contentful-paint',
        buffered: true,
      });
    });
  });

  await expect(largestContentfulPaint).toBeLessThan(2500);
});
Run Code Online (Sandbox Code Playgroud)

javascript reactjs playwright playwright-test

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

为什么 React Js 被称为单页应用程序

我经常听到和看到关于 React 是单页应用程序的帖子,但从来不明白什么是 SPA,很多人说它不会重新加载页面,但我不明白为什么,所以你们能用简单的例子解释一下吗?

single-page-application reactjs

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

在 React Js 中使用多个复选框过滤列表

大家好,我正在尝试根据条件过滤复选框的 onClick 对象数组列表,但句柄方法中的 else 条件返回给我一个状态不会改变的相同数组,所以我想要删除默认列表当我尝试取消选中所有列表上的复选框时,已过滤列表。

import React from "react";
import "./Search.css";

class Search extends React.Component {
  constructor() {
    super();
    this.state = {
      searchLists: [
        {
          id: 1,
          type: "All",
          name: "Akash",
          location: "bangalore",
          experience: 1
        },
        {
          id: 2,
          type: "FullTime",
          name: "feroz",
          location: "mumbai",
          experience: 3
        },
        {
          id: 3,
          type: "PartTime",
          name: "Farheen",
          location: "agra",
          experience: 5
        },
        {
          id: 4,
          type: "Freelancer",
          name: "Raju",
          location: "chennai",
          experience: 6
        },
        {
          id: 5,
          type: "All",
          name: "Asif",
          location: …
Run Code Online (Sandbox Code Playgroud)

javascript setstate reactjs react-component

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

Material-UI:如何将 Drawer 组件置于 AppBar 下方

我正在使用 Material UI 抽屉组件,我希望抽屉位于应用栏下方,我想在其中切换汉堡包图标的 onclick 以打开和关闭,当我单击汉堡包图标时,它应该打开下面的抽屉并 onclick它也应该关闭,我不希望汉堡包图标在单击它时移动,它应该静态在一个地方。它不应该移动,只有抽屉应该打开和移动。我如何在材质中实现它用户界面 https://codesandbox.io/s/material-demo-forked-ehs05?file=/demo.js:0-6433

import React from 'react';
import clsx from 'clsx';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import CssBaseline from '@material-ui/core/CssBaseline';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import Typography from '@material-ui/core/Typography';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import …
Run Code Online (Sandbox Code Playgroud)

javascript css reactjs material-ui

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