今天我正在处理一个 React/Gatsby 网站。我想在每个页面上制作横幅。我想制作一个组件并使用一个参数。我使用我的照片作为参数。
但每次我收到错误:“无法读取未定义的属性‘道具’ ”
索引.js:
<Banner image={<image parameter>} alt="..."/>
Run Code Online (Sandbox Code Playgroud)
在我的 Banner.js 上:
import React from 'react';
const Banner = () => {
return (
<img src={ this.props.image } className={'banner-fullwidth'} alt={"Banner on page"}/>
)
}
export default Banner;
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题?
还是遇到了问题:
即使我用箭头函数中的道具改变了我的函数。
这是 Java 库中的一个片段:
public final boolean compareAndExchangeAcquire(boolean expectedValue, boolean newValue) {
return (int)VALUE.compareAndExchangeAcquire(this,
(expectedValue ? 1 : 0),
(newValue ? 1 : 0)) != 0;
}
Run Code Online (Sandbox Code Playgroud)
它来自AtomicBoolean课堂。演员怎么能int返回一个boolean?
我的主要问题:compareAndExchangevs之间有什么区别compareAndExchangeAcquire?
通俗地说:在申请之前xxxAcquire和之后写的语句xxxRelease可以自由重新排序xxx。
看看我的代码:
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
try
{
if (Directory.Exists(Path.Combine(desktopPath, "Hackers.avi")))
Directory.Delete(Path.Combine(desktopPath, "Hackers.avi"), true);
Run Code Online (Sandbox Code Playgroud)
运行文件后我的桌面上仍然存在,为什么?
我知道我会因为提出这个问题而听起来很吵,但是我可以通过简单的方法将node.js包含在我的html或我可以包含的一些Google API库中.
喜欢:
<script>google.load(xxxx)</script>
**or**
<script src="xxxx"></script>
Run Code Online (Sandbox Code Playgroud)
我知道这是我本周提出的第二个问题,但是......我必须在某个地方学习吗?
提前致谢.
请参阅显示我的数据和运行宏后预期数据的附加图像,
请有人帮助我在宏...

子 Complete_sepy_load_macro()
将 ws、s1、s2 调暗为工作表
Dim rw、rw2、rw3、col1、count1、w、x、y、z、cw 作为整数
将 text1 调暗为字符串
Dim xwalk As String
Dim TOSes 作为变体
Application.DisplayAlerts = False
For each ws in Sheets
如果 ws.Name = "CMC_SEPY_SE_PYMT" 然后 Sheets("CMC_SEPY_SE_PYMT").Delete
下一个
Application.DisplayAlerts = True
设置 s2 = ActiveSheet
g = s2.Name
Sheets.Add.Name = "CMC_SEPY_SE_PYMT"
设置 s1 = Sheets("CMC_SEPY_SE_PYMT")
s1.Cells(1, 1) = "SEPY_PFX"
s1.Cells(1, 2) = "SEPY_EFF_DT"
s1.Cells(1, 3) = "SESE_ID"
s1.Cells(1, 4) = … 我在解密字符串时遇到了上述异常.
以下是我的代码:
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
public class EncryptAndDecrypt {
public static Cipher createCipher () throws Exception{
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
return cipher;
}
public static KeyPair generateKey () throws NoSuchAlgorithmException{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance ("RSA");
keyGen.initialize(1024);
KeyPair key = keyGen.generateKeyPair();
return key;
}
public static byte [] encrypt (String str, Cipher cip, KeyPair key) {
byte [] cipherText = null;
try {
byte [] plainText = str.getBytes("UTF8");
cip.init(Cipher.ENCRYPT_MODE, key.getPublic());
cipherText = cip.doFinal(plainText);
} catch (Exception …Run Code Online (Sandbox Code Playgroud) 我正在尝试测试文件,如果希望它测试所有文件,当一个不存在时,它将执行代码.我试过了,||但它似乎没有用,所以我想知道它是否是我需要使用的正确的.
例:
if (File.Exists("//1.txt") || File.Exists("//2.txt") || File.Exists("//3.txt") )
{
//DO NOTHING
}
else
{
File.Create("//1.txt");
File.Create("//2.txt");
File.Create("//3.txt");
}
Run Code Online (Sandbox Code Playgroud)
所以,
if(This(哪个是真的)或This(哪个是真的)或This(哪个是FALSE)){
}
我正在比较两个标题列表以获得第三个列表。在这种情况下,第一个列表是艺术家的所有专辑的列表,第二个列表是库中所述艺术家的专辑的列表,第三个列表是库中缺少的专辑。
我的代码运行良好,可以处理丢失的标点符号和重音字符,但当涉及到可以是“<word 1> 和 <word 2>”或“<word 1> & <word 2>”的标题时,它会失败甚至“<单词 1> + <单词 2>”。
最简单的解决方案是对所有标题执行类似的操作:
title = title.Replace(" + ", " and ").Replace(" & ", " and ");
Run Code Online (Sandbox Code Playgroud)
以便它们都具有相同的形式。注意:我正在检查由空格包围的符号,希望确保我得到符号表示“和”的情况。
然而,这并不让我觉得非常有效,尤其是对于一长串标题。
是否有更有效的方法来进行文本替换,或者更好的是,有一种比较原始字符串以获得有效匹配的方法?
我收到一个错误,告诉我有预期的标识符?
码:
[HttpPost]
public ActionResult EditProduct(int id, FormCollection collection)
{
ProductRepository repo = new ProductRepository();
var product = repo.GetProductID(id);
string Pid = collection["Pid"];
string name = collection["PName"];
string type = collection["PType"];
string deal = collection.["PDeal"];
string desc = collection.["PDescription"];
string price = collection.["PPrice"];
repo.Save();
return View("index");
}
Run Code Online (Sandbox Code Playgroud) 我现在很困惑.我有一个ArrayList,我添加一个元素到ArrayList.现在ii尝试list.get(0)并抛出IndexOutOfBounds.......它变得更加奇怪:简而言之它看起来像这样:
ArrayList<SomeCustomClass> list = new ArrayList<SomeCustomClass>();
list.add(new SomeCustomClass());
int index = 0;
for(index = 0;index < list.size();index++){
if(list.get(index).something < somethingOther){ //Throws no error
break;
}
}
SomeCustomClass blarg = list.get(index); //Throws IndexOutOfBounds
Run Code Online (Sandbox Code Playgroud)
...为了确保,我在控制台中测试索引的值,它们都为零,但第二个引发错误.
提前致谢
编辑:Sry.我在问题中犯了错误.现在问题应该是正确的.是的:我检查索引是否有时超过0(它不是),如果"if"为真(它是)
编辑:搞笑:我手动改变指数为0,它是sais:
线程"Thread-2"中的异常java.lang.IndexOutOfBoundsException:索引:0,大小:0
我将0更改为1并且:
线程"Thread-2"中的异常java.lang.IndexOutOfBoundsException:索引:1,大小:1
(我只更改了错误来自的行中的值)Java是否在拖我?>.<:P
似乎有时与 ## 连接确实有效,有时则不起作用。
尽管它对于某些用途显然是至关重要的,但它是一个不可靠的功能。
使用##有一套明确的规则吗?
一个例子是:
file1.h
#define concat(a,b) a##b
#define BAR bar
extern int concat(fu,BAR) ();
Run Code Online (Sandbox Code Playgroud)
这里 concat 产生 fuBAR 而不是 fubar。
一个例子是:
file2.h
#define BAR bar
extern int fu##BAR ();
Run Code Online (Sandbox Code Playgroud)
这里 ## 会产生一个关于代码中杂散 ## 的错误。
我使用 jquery 获取 html img 元素的路径,如下所示:
path = $("#img_elemnt_id).attr('src')
Run Code Online (Sandbox Code Playgroud)
它给了我一个字符串
path = "C:\User\pic.jpg"
Run Code Online (Sandbox Code Playgroud)
我需要在函数中使用该字符串,但仅当路径如下时才有效
path ="C:\\User\\pic.jpg"
Run Code Online (Sandbox Code Playgroud)
知道如何做到这一点吗?
更新:您的答案不起作用。
path = "C:\\User\\pic.jpg"
Run Code Online (Sandbox Code Playgroud)
在该功能中有效,但您的答案不起作用。
path = "C:\User\pic.jpg"
path = path.replace('\\,'\\\\')
console.log(path)
Run Code Online (Sandbox Code Playgroud)
输出
C:Userpic.jpg
Run Code Online (Sandbox Code Playgroud) c# ×4
java ×3
javascript ×3
node.js ×2
arraylist ×1
c ×1
comparison ×1
concurrency ×1
electron ×1
excel ×1
gatsby ×1
google-api ×1
html ×1
if-statement ×1
java-14 ×1
jquery ×1
jsx ×1
reactjs ×1
replace ×1
rsa ×1
string ×1
vba ×1