要出口:
会议1:
let user = gun.user()
user.create('Bob','password123',console.log)
user.auth('Bob' ,'password123',console.log)
JSON.stringify(user._.sea) // prompt user to export / "download"
导入:
会议2:
let user = gun.user()
let imported_JSON //Prompt user to import JSON as imported_JSON
let pair = JSON.parse(imported_JSON)
user.auth(pair,console.log) // user now authorised on session 2
我的最终解决方案是不使用SystemD。随着Windows 11的发布,WSL已添加了一项新功能,以在WSL启动上运行脚本。如果您从Microsoft Store安装WSL(需要KB5020030),则此功能现在也可供Windows 10用户使用,该功能应在可选更新下可用)。
创建file/etc/wsl.conf,
[boot]
command = bash /etc/[path to startup script]
在我的情况下,我使用了路径“ /etc/wsl-services-start.sh”此shell脚本仅
service apache2 start
service mysql start
启动apache2,而mysql是我唯一需要的systemd,所以这对我来说很好。
Metadaitem
是一个结构,AFAIK您无法在XAML中初始化结构。
我还建议您在样本中创建一个metadaitem
的集合。
也就是说,我使用附加的属性建立了此代码,并实现了您要做的事情。命名是冗长的,但我认为在这种情况下,我会更容易获得它的代表。我希望这会有所帮助。
metadatacontrolextension.cs
using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Xaml;
using System.Collections.Generic;
namespace MetadataControlExtension;
public class MetadataControlExtensionItem
{
public string Label { get; set; } = string.Empty;
}
public class MetadataControlExtensionItemList : List<MetadataControlExtensionItem>
{
}
public class MetadataControlExtension : DependencyObject
{
public static IEnumerable<MetadataControlExtensionItem> GetItemsSource(DependencyObject obj)
{
return (IEnumerable<MetadataControlExtensionItem>)obj.GetValue(ItemsSourceProperty);
}
public static void SetItemsSource(DependencyObject obj, IEnumerable<MetadataControlExtensionItem> value)
{
obj.SetValue(ItemsSourceProperty, value);
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.RegisterAttached(
"ItemsSource",
typeof(IEnumerable<MetadataControlExtensionItem>),
typeof(MetadataControlExtension), new PropertyMetadata(0, OnItemsSourcePropertyChanged));
private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is MetadataControl metadataControl && e.NewValue is IEnumerable<MetadataControlExtensionItem> itemsSource)
{
List<MetadataItem> metadataItems = new();
foreach (MetadataControlExtensionItem item in itemsSource)
{
metadataItems.Add(new MetadataItem() { Label = item.Label });
}
metadataControl.Items = metadataItems;
}
}
}
mainwindow.xaml
<Window
x:Class="MetadataControlTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:ex="using:MetadataControlExtension"
mc:Ignorable="d">
<Grid>
<controls:MetadataControl>
<ex:MetadataControlExtension.ItemsSource>
<ex:MetadataControlExtensionItemList>
<ex:MetadataControlExtensionItem Label="1st Item"/>
<ex:MetadataControlExtensionItem Label="2nd Item"/>
<ex:MetadataControlExtensionItem Label="3rd Item"/>
<ex:MetadataControlExtensionItem Label="4th Item"/>
<ex:MetadataControlExtensionItem Label="5th Item"/>
</ex:MetadataControlExtensionItemList>
</ex:MetadataControlExtension.ItemsSource>
</controls:MetadataControl>
</Grid>
</Window>
您可以使用querySelectorall
选择所有父母。您发布的代码未正确格式化,因此这就是我可以从中得到的。
function close() {
let parents = document.querySelectorAll('.container_blur')'
if ( parents.length < 1 ) return;
parents.forEach(parent => {
setTimeout(function () {
parent.style.opacity = 0;
parent.style.transition = 'opacity 0.3s ease-out';
}, 10);
setTimeout(function () {
parent.style.display = 'none';
}, 300);
});
}
OR(||
)操作员始终返回首先真实值,yellow
在您的情况下。
如果您只想在这两个之间进行选择,则可以将它们放入数组中并使用 math.random()
生成一个随机数。如果此数字小于0.5
,则可以选择第一个数字,如果它更大,请选择第二个:
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
您可以这样更新代码:
.setColor(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
我认为对地图
方法的方法有误解。该方法通常用于原始值保持不变的数据转换。您在这里真正做的是造成副作用,MAP
方法在这里根本没有帮助您。
只需使用循环的即可。这并不是说您使用地图和插入器保存击键。
但是,您提到您有一个vec&lt;&amp; vec&gt;
。拥有这种类型似乎不适合您的目的。克隆整个vec只是为了添加1个元素,对于性能是可怕的。
我看到了2个选择:要么拥有完全拥有,即vec&lt; vec&gt;
,要么只是使Inner vec
sable可变,如vec&amp; mut中vec&gt;
。
这是第一个选项,我认为这是最惯用的:
fn main() {
let mut vec_of_strings = vec![
vec!["a1", "b2", "c3"],
vec!["d1", "e2", "f3"],
vec!["g1", "h2", "i3"]
];
for vec in vec_of_strings.iter_mut() {
vec.push("something");
}
println!("{vec_of_strings:?}");
}
如果以拥有形式的形式不可接受,那么另一种选择是使用vec&&amp&amp; mut vec vec&gt;
:
fn main() {
fn main() {
let mut vec_of_strings = vec![
vec!["a1", "b2", "c3"],
vec!["d1", "e2", "f3"],
vec!["g1", "h2", "i3"]
];
//suppose somehow a function gave you this:
let vec_of_mut_strings: Vec<&mut Vec<_>> = vec_of_strings
.iter_mut()
.collect();
for vec in vec_of_mut_strings {
vec.push("something");
}
//notice that the original vec_of_strings change
println!("{vec_of_strings:?}");
}
}
我的代码的问题在于我正在使用和异步功能来获取我的数据,这并没有使数据显示。删除异步/等待解决问题。
const getEventsData = () => {
firebase.firestore().collection("Events").get().then((snapshot) => {
const events = snapshot.docs.map(event => event.data());
setEventsData(events)
console.log(events)
}).catch((e) => {
console.log(e + "fetching error")
})
}
以下摘录来自 python关于self 的文档:
与Modula-3中一样,没有用于从其方法引用对象成员的速记(在Python中):方法函数是用代表对象的明确的第一个参数声明的,该函数由呼叫。
通常,方法的第一个论点称为自我。这无非是一种惯例:“自我”这个名字绝对没有特殊的意义。但是,请注意,通过不遵循《惯例》,您的代码可能不太对其他Python程序员读取,并且也可以想象,可以编写依赖此类约定的类浏览器程序。
。
有关更多信息,请参见 python文档教程。
实际上,我认为它可以按预期工作,但是问题是,当尚未渲染这些类别的组件时,您正在尝试将单击处理程序放置。
您可以将这些jQuery代码放入函数中,将其导入您的React组件,然后在“ ComponentDidMount”中使用它,或者根据您使用的组件来使用空的依赖项(功能组件中的ComponentDidMount(例如ComponentDidmount))。
这样,您将确保渲染所有内容,并且可以将其放置在何处。
要检查此问题,请尝试在代码中使用console.log $(“。移动滤波器-btn”)。我希望它是不确定的。
这也不是好主意。它可能效果不太好,并且会产生很多错误或维护问题
尝试直接运行应用程序:
dotnet serije.dll
(有正确的路径)
可能会出现一个错误:
找不到框架
您需要提及,在向量的情况下,正在使用哪种标准C ++。例如带有[代码]的文件名,因此要为使用向量的[代码]创建可执行文件,终端代码将为 g ++ -Std = C ++ 11 Code.cpp&amp;&amp; ./a.out 执行并运行代码
这是一个快速而肮脏的解决方案。阈值似乎可以正常工作,但首先侵蚀了该区域并扩张它:
read_image (Image, 'D:/OneDrive - Subpixel d.o.o/Other/Stackoverflow/3/4e7Za.png')
rgb1_to_gray (Image, GrayImage)
equ_histo_image (GrayImage, ImageEquHisto)
threshold (ImageEquHisto, Regions, 145, 227)
fill_up (Regions, RegionFillUp)
erosion_circle (RegionFillUp, RegionErosion, 30.5)
dilation_circle (RegionErosion, RegionDilation, 30.5)
似乎颜色相机可以更好地解决您的问题,因为板条箱确实具有其他颜色。这是一个选择吗?
返回字符串阵列中的变体数组值,
- 无论执行此操作的动机如何(绩效问题,保持明确,以一行代码等执行等),您可以使用
strarray
函数。
Option Explicit
'Option Base 1 ' try and see that 'sArr' will always be zero-based
' To ensure that 'vArr' is zero-based, use 'vArr = VBA.Array("a", "b", "c")'.
Sub StrArrayTEST()
' Note that the 'vArr' parentheses are necessary to prevent
' 'Compile error: Type mismatch: array or user-defined type expected'...
Dim vArr() As Variant: vArr = Array("a", "b", "c") ' try 'vArr = Array()'
' ... in the following 'sArr=...' line, where 'vArr' is highlighted.
Dim sArr() As String: sArr = StrArray(vArr)
' The following line instead, doesn't compile with the same error
' (because of 'ByRef' in the function?) with 'Array' highlighted.
'Dim sArr() As String: sArr = StrArray(Array("a", "b", "c"))
Debug.Print "String Array Values"
Debug.Print "Index", "String"
Dim n As Long
For n = 0 To UBound(sArr)
Debug.Print n, sArr(n)
Next n
Debug.Print "Array LB/UB Vartype TypeName"
Debug.Print "Variant [LB=" & LBound(vArr) & ",UB=" & UBound(vArr) & "]" _
& " VT=" & VarType(vArr) & " TN=" & TypeName(vArr)
Debug.Print "String [LB=" & LBound(sArr) & ",UB=" & UBound(sArr) & "]" _
& " VT=" & VarType(sArr) & " TN=" & TypeName(sArr)
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Purpose: Returns the values from a variant array ('VariantArray'),
' converted to strings, in a zero-based string array.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function StrArray( _
VariantArray() As Variant) _
As String() ' 'ByVal VariantArray() As Variant' is not possible
Const ProcName As String = "StrArray"
Dim AnErrorOccurred As Boolean
On Error GoTo ClearError ' turn on error-trapping
Dim LB As Long: LB = LBound(VariantArray)
Dim UB As Long: UB = UBound(VariantArray)
Dim StringArray() As String: ReDim StringArray(0 To UB - LB)
Dim n As Long
For n = LB To UB
StringArray(n - LB) = CStr(VariantArray(n))
Next n
ProcExit:
On Error Resume Next ' defer error-trapping (to prevent endless loop)
If AnErrorOccurred Then
' Ensure the result is a string array.
StrArray = Split("") ' LB = 0, UB = -1
Else
StrArray = StringArray
End If
On Error GoTo 0 ' turn off error-trapping (before exiting)
Exit Function
ClearError:
Debug.Print "'" & ProcName & "' Run-time error '" _
& Err.Number & "':" & vbLf & " " & Err.Description
AnErrorOccurred = True
Resume ProcExit ' continue error-trapping
End Function
在创建表之前,您需要使用用户名和密码连接。
在此处的直接答案之外,应该注意python 2和3之间的另一个关键区别。 几乎所有主要差异都涉及您何时应该使用任何一个版本。 此博客文章也做得很好目前
python语言。在继续沿Python 3路线继续前,您应该考虑上述文章。您不仅需要更改某些语法,还需要考虑哪些软件包可供您使用(Python 2的优势)以及可以在您的代码中进行的潜在优化(Python 3的优势) 。
Outside of the direct answers here, one should note the other key difference between python 2 and 3. The official python wiki goes into almost all of the major differences and focuses on when you should use either of the versions. This blog post also does a fine job of explaining the current python universe and the somehow unsolved puzzle of moving to python 3.
As far as I can tell, you are beginning to learn the python language. You should consider the aforementioned articles before you continue down the python 3 route. Not only will you have to change some of your syntax, you will also need to think about which packages will be available to you (an advantage of python 2) and potential optimizations that could be made in your code (an advantage of python 3).
“语法”是什么:在呼叫到“ print”中缺少括号。在python中的意思?