我刚刚开始从Electron Docs学习 Electron 。我使用 ES6,(import/export)
而他们使用require
.
我已经添加type:module
了 mypackage.json
并且将js
扩展名更改为mjs
,但是每次运行npm start
( My node version => 14 )时,我都会收到此错误:
App threw an error during load
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/alaeddine/Desktop/electron-app/petro-book/main.mjs
at Module.load (internal/modules/cjs/loader.js:933:11)
at Module._load (internal/modules/cjs/loader.js:776:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
at loadApplicationPackage (/Users/alaeddine/Desktop/electron-app/petro-book/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:110:16)
at Object.<anonymous> (/Users/alaeddine/Desktop/electron-app/petro-book/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:222:9)
at Module._compile (internal/modules/cjs/loader.js:1078:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
at Module.load (internal/modules/cjs/loader.js:935:32)
at Module._load (internal/modules/cjs/loader.js:776:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
Run Code Online (Sandbox Code Playgroud)
包.json:
App threw an …
Run Code Online (Sandbox Code Playgroud) 我正在使用JavaFX项目.我正在使用ControlFx的 Autcomplete TextField .每次我在数据库表中添加新行,它应该更新自动完成,我这样做但我的问题是显示双上下文菜单,我们可以说双重自动完成,因为我调用方法创建自动完成每次添加表中的新元素.
当我单击一个选项卡时,editBill
我调用此方法:
public void showEditBill() {
if (!BillPane.getTabs().contains(EditBillTab)) {
BillPane.getTabs().add(EditBillTab);
}
SingleSelectionModel<Tab> selectionModel = BillPane.getSelectionModel();
selectionModel.select(EditBillTab);
/*it should remove the old autocomplete from textfield*/
pushBills(); //Call for cheking new items
}
Run Code Online (Sandbox Code Playgroud)
pushBills方法():
public void pushBills() {
ArrayList list = new ArrayList<>();
bills = new BillHeaderDao().FindAll();
for (int i = 0; i < bills.size(); i++) {
list.add(bills.get(i).getIdClient());
}
//How can i remove the old bind before bind again
autoCompletionBinding = TextFields.bindAutoCompletion(SearchBill, SuggestionProvider.create(list));
} …
Run Code Online (Sandbox Code Playgroud) 我有一个数组[1, 2, 3]
,我想将它传输到具有嵌套父子 对象系列的对象,如下所示:
{ value: 1, rest: { value: 2, rest: { value: 3, rest: null } }
Run Code Online (Sandbox Code Playgroud)
如果我有一个数组 [1, 2, 3, 4]
,结果将是这样的:
{ value: 1, rest: { value: 2, rest: { value: 3, rest: { value:4, rest:null } }
Run Code Online (Sandbox Code Playgroud)
我最大的努力是这段代码:
{ value: 1, rest: { value: 2, rest: { value: 3, rest: null } }
Run Code Online (Sandbox Code Playgroud)
我刚刚开始使用 NEXTJS 13 版本,它让我有点困惑。
嗯,这是我的项目结构:
user.ts
我的文件夹中有一个文件api
,其中包含以下代码:
const token = process.env.TOKEN;
export async function GET(request: Request) {
return new Response('Hello, Next.js!');
}
export async function POST(request: Request) {
const query = `
query {
user(login: "MenaiAla") {
avatarUrl
}
`;
fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
})
.then((response) => response.json())
.then((data) => console.log(data));
}
Run Code Online (Sandbox Code Playgroud)
在我的中page.tsx
,我有一个from
方法submit
:
'use client';
import React from 'react';
import …
Run Code Online (Sandbox Code Playgroud) 我按照RFC DOCUMENTATION在 Java 中实现该算法。使用相同的测试代币共享值1234567890
附录 B和我得到了相同的结果。
但我不明白seed32
模式seed64
,在示例中,我们有这样的模式:
// Seed for HMAC-SHA1 - 20 bytes
String seed = "3132333435363738393031323334353637383930";
// Seed for HMAC-SHA256 - 32 bytes
String seed32 = "3132333435363738393031323334353637383930" +
"313233343536373839303132";
// Seed for HMAC-SHA512 - 64 bytes
String seed64 = "3132333435363738393031323334353637383930" +
"3132333435363738393031323334353637383930" +
"3132333435363738393031323334353637383930" +
"31323334";
Run Code Online (Sandbox Code Playgroud)
和:
3132333435363738393031323334353637383930
Run Code Online (Sandbox Code Playgroud)
是 ASCII 字符串的十六进制值:
12345678901234567890
Run Code Online (Sandbox Code Playgroud)
假设我有这个 ASCII 字符串:
aaa.bbbbbbbb.ccc@gmail.comAAAABBBBBCCCCCCDDD
Run Code Online (Sandbox Code Playgroud)
等效的十六进制是:
6161612e62626262626262622e63636340676d61696c2e636f6d414141414242424242434343434343444444
Run Code Online (Sandbox Code Playgroud)
那么我如何从这个十六进制结果中获得种子,种子 32,种子 64?
string seed="what's the seed value"
string seed32="what's the seed32 …
Run Code Online (Sandbox Code Playgroud) 我学习了 nextJS,并尝试使用动态路由和包罗万象的路由。但是我遇到了一个基本问题,我不确定如何在 getStaticPaths 中以数组形式提供数据。
\n这是我当前的代码:
\nimport Link from \'next/link\';\n\nfunction test({ variable }) {\n return (\n <>\n <div>\n <h1>{variable.var}</h1>\n\n <Link href="/">\n <a>\xe2\x86\x90 Back</a>\n </Link>\n </div>\n </>\n );\n}\n\nexport async function getStaticProps({ params }) {\n const variable = params.variable;\n return {\n props: {\n variable,\n },\n };\n}\n\nexport async function getStaticPaths() {\n return {\n fallback: false,\n paths: [\n {\n params: {\n variable: \'testi\',\n },\n },\n ],\n };\n}\n\nexport default test\n
Run Code Online (Sandbox Code Playgroud)\n我收到错误:
\nError: A required parameter (variable) was not provided as an array …
Run Code Online (Sandbox Code Playgroud) 我想通过 React边做边学Typescript,所以我在我create-react-app
的默认测试文件中手动从 JS 迁移到 TS App.test.ts
:
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />); // There's an error here
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
Run Code Online (Sandbox Code Playgroud)
有这个错误:
'App' refers to a value, but is being used as a type here. Did you mean 'typeof App'?
Run Code Online (Sandbox Code Playgroud) 我会使用带有函数的 v-bind 将按钮绑定到输入:
我的模板中的代码:
<input
type="email"
v-model="email"
v-bind:placeholder="$t('fields.email_place_holder')"
/>
<input v-bind :disabled="{isDisable}"type="submit" v-bind:value="$t('buttons.notify_me')" class="notify-me-button" />
Run Code Online (Sandbox Code Playgroud)
我的脚本中的代码:
methods:{
isDisable(){ return email.lenght>0 }}
Run Code Online (Sandbox Code Playgroud)
但是button
没有改变它的状态,我试图用同样的方式改变css样式,结果是一样的。问题是按钮在返回的第一个值上响应一次isDisable()
。
我有以下代码片段,
var code = 895804220010013030;
var last = code.slice(-2);
var n = last.includes(00, 01, 10, 11, 20, 21, 30, 31 );
if (n===true) {
alert(n)
} else {
alert('false')
}
Run Code Online (Sandbox Code Playgroud)
但它会引发语法错误,它有效的唯一方法是将引号放在数字上
var code = 895804220010013030;
Run Code Online (Sandbox Code Playgroud)
但我需要在不加引号的情况下运行它。
p
我有一个 TextField 组件,右侧包含一个单元 ( )。我动态地更改了该单元和文本值之间的填充useEffect
,但是当我想确保它使用 Cypress 组件测试正确工作时,我阻止了。
import classNames from "classnames";
import { IProps } from "./type";
import styles from "./style.module.css";
import { useEffect, useRef } from "react";
const TextField = ({
ID,
value,
placeholder,
type,
rounded,
outline,
disabled,
icon,
unit,
onChange,
onFocus,
onBlur,
}: IProps) => {
const unitRef = useRef<HTMLParagraphElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
// How to test this hook
useEffect(() => {
if (unitRef.current && inputRef.current) {
const unitWidth = unitRef.current.getBoundingClientRect().width;
inputRef.current.style.paddingRight = `${unitWidth …
Run Code Online (Sandbox Code Playgroud) 我正在尝试tableView
使用Apache POI导出到excel
一切都很好,但是我需要导出所有表而不仅仅是项目,我的意思是使用此代码时使用列名:
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet spreadsheet = workbook.createSheet("sample");
HSSFRow row = null;
for (int i = 0; i < TousEmpSusp.getItems().size(); i++) {
row = spreadsheet.createRow(i);
for (int j = 0; j < TousEmpSusp.getColumns().size(); j++) {
row.createCell(j).setCellValue(TousEmpSusp.getColumns().get(j).getCellData(i).toString());
}
}
Run Code Online (Sandbox Code Playgroud)
它只导出项目,我试图像这样修改它:
for (int j = 0; j < TousEmpView.getColumns().size(); j++) {
row.createCell(j).setCellValue(TousEmpView.getColumns().get(j).getText());
}
for (int i = 0; i < TousEmpView.getItems().size(); i++) {
row = spreadsheet.createRow(i+1);
for (int j = 0; j < TousEmpView.getColumns().size(); …
Run Code Online (Sandbox Code Playgroud) 今天早上我没能通过这次面试。
给定一个整数数组,执行一些k
操作,每个操作包括删除一个元素并将其除以 2并计算 ceil然后用新元素替换该元素。
最后,最小化最终数组的结果
例子:
nums=[10,20,7]
k=4
Run Code Online (Sandbox Code Playgroud)
最终数组将是:
[5,5,4]
Run Code Online (Sandbox Code Playgroud)
总和结果:
5+5+4=14
Run Code Online (Sandbox Code Playgroud)
设想 :
初始数组: [10,20,7]
选择7
:[10,20,4]
选择10
:[5,20,4]
选择20
:[5,10,4]
选择10
:[5,5,4]
结果:
5+5+4 = 14
Run Code Online (Sandbox Code Playgroud)
我的代码(未完成):
function minSum(num, k) {
return num.map(value => Math.ceil(value / 2)).reduce((value, acc) => acc + value, 0)
}
console.log(minSum([10, 20, 7]))
Run Code Online (Sandbox Code Playgroud)
什么让我困惑:
• 我们如何根据操作次数挑选元素?
编辑 :
因为我收到了 2 个关闭请求,让我澄清一下:
假设我们从索引0
到最后一个索引选择元素,我的代码中遗漏了什么来满足k
操作?
我有一个表格:
\n\nconst Form = ({ data }: { data: BuildingAPIResponseData }) => {\n const dispatch = useDispatch()\n const { push } = useRouter() // the issue comes from this\n // other code\n}\n
Run Code Online (Sandbox Code Playgroud)\n我的测试:
\nimport { Provider } from "react-redux"\n\nimport { store } from "@/redux/store"\n\nimport Form from "."\nimport MockRouter from "../../../../../../cypress/mocks/next-router"\nimport { BuildingAPIResponseData } from "../../types"\n\ndescribe("Building Details IForm", () => {\n const zipCode = "63110"\n const city = "Rodgau"\n const street = "Liebigstra\xc3\x9fe"\n const houseNumber = "2"\n\n const …
Run Code Online (Sandbox Code Playgroud) javascript ×4
binding ×2
cypress ×2
java ×2
javafx-8 ×2
next.js ×2
next.js13 ×2
reactjs ×2
algorithm ×1
apache-poi ×1
arrays ×1
autocomplete ×1
byte ×1
controlsfx ×1
electron ×1
node.js ×1
npm ×1
typescript ×1
vuejs2 ×1