我发现了。
您只需要使用此功能:
function woocommerce_product_category( $args = array() ) {
$woocommerce_category_id = get_queried_object_id();
$args = array(
'parent' => $woocommerce_category_id
);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
echo '<ul class="woocommerce-categories">';
foreach ( $terms as $term ) {
echo '<a href="' . esc_url( get_term_link( $term ) ) . '"><li class="woocommerce-product-category-page">';
woocommerce_subcategory_thumbnail( $term );
echo '<h2>';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
echo $term->name;
echo '</a>';
echo '</h2>';
echo '</li></a>';
}
echo '</ul>';
}
}
add_action( 'woocommerce_before_shop_loop', 'woocommerce_product_category', 100 );
我希望它能帮助某人。谢谢
您可以尝试一下。请根据您的要求编辑弹性值
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2
child :Text(
year,
style: Theme.of(context).textTheme.subtitle2,
overflow: TextOverflow.ellipsis,
),
)
Flexible(
flex : 8
child: Row(
mainAxisAlignment : MainAxisAlignment.end
mainAxisSize : MainAxisSize.min
children : [
icon,
SizedBox(width: 0.1),
Flexible(
child: Text(
figure,
style: Theme.of(context).textTheme.subtitle2,
overflow: TextOverflow.ellipsis,
),
)
]
)
)
]
)
您可以使用combn()
创建成对索引,并使用slice()
来扩展数据框架。然后仅通过这些行对进行分组并总结。我假设您需要成对组合,但是如果需要,它可以适用于较大的组合。一些处理组的代码&LT;包括2,但如果这些数据不存在,则可以删除。
library(dplyr)
library(purrr)
df1 %>%
group_by(id) %>%
slice(c(combn(seq(n()), min(n(), 2)))) %>%
mutate(id2 = (row_number()-1) %/% 2) %>%
group_by(id, id2) %>%
summarise(name = toString(name),
across(where(is.numeric), sum), .groups = "drop") %>%
select(-id2) %>%
bind_rows(df1 %>%
group_by(id) %>%
filter(n() > 1), .) %>%
arrange(id) %>%
ungroup()
# A tibble: 6 × 4
id name number value
<chr> <chr> <int> <int>
1 a bob 1 1
2 a jane 2 2
3 a bob, jane 3 3
4 b mark 1 1
5 b brittney 2 2
6 b mark, brittney 3 3
编辑:
为了适应所有可能的组合,您可以迭代到最大组大小的值。使用编辑的数据,该数据在第一个组中添加了几行:
map_df(seq(max(table(df2$id))), ~
df2 %>%
group_by(id) %>%
slice(c(combn(seq(n()), .x * (.x <= n())))) %>%
mutate(id2 = (row_number() - 1) %/% .x) %>%
group_by(id, id2) %>%
summarise(name = toString(name),
across(where(is.numeric), sum), .groups = "drop")
) %>%
select(-id2) %>%
arrange(id)
# A tibble: 18 × 4
id name number value
<chr> <chr> <int> <int>
1 a bob 1 1
2 a jane 2 2
3 a sophie 1 1
4 a jeremy 2 2
5 a bob, jane 3 3
6 a bob, sophie 2 2
7 a bob, jeremy 3 3
8 a jane, sophie 3 3
9 a jane, jeremy 4 4
10 a sophie, jeremy 3 3
11 a bob, jane, sophie 4 4
12 a bob, jane, jeremy 5 5
13 a bob, sophie, jeremy 4 4
14 a jane, sophie, jeremy 5 5
15 a bob, jane, sophie, jeremy 6 6
16 b mark 3 5
17 b brittney 4 6
18 b mark, brittney 7 11
df2
的数据:
df2 <- structure(list(id = c("a", "a", "a", "a", "b", "b"), name = c("bob",
"jane", "sophie", "jeremy", "mark", "brittney"), number = c(1L,
2L, 1L, 2L, 3L, 4L), value = c(1L, 2L, 1L, 2L, 5L, 6L)), class = "data.frame", row.names = c(NA,
-6L))
我找到了Tsengs回答的解决方案,但希望在这里描述它。
解决方案是在另一个问题的答案中找到的,但是这个问题完全不同(我也扩展了答案),因此我不认为这个问题应该被标记为重复。
答案是
” 的每个IIS网站上的值
键aspnetcore_environment 这样做是:
- 转到IIS中的应用程序,然后选择
配置编辑
。 - 选择
配置编辑器
- 选择
system.webserver/aspnetcore
(rc2 and rtm)或system.webserver/httpplatform
(rc1(rc1)) /code> combobox - 选择
applicationhost.config ...
在 combobox中中。 - 单击
EnviroMentVariables
元素,然后打开编辑窗口。 - 设置您的环境变量。
- 关闭窗口,然后单击“应用”。
- 另外
,您可以修改applicationhost.config
file(通常位于c:\ windows \ system32 \ inetsrv \ inetsrv \ config \ applicationhost.config
,并在下面添加以下条目root &lt; configuration&gt;
标签,其中“ my-iis site”是IIS网站的名称。
<location path="my-iis-site">
<system.webServer>
<aspNetCore>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="DEV" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
Azure SQL数据库支持完整的备份,差速器备份和事务日志备份。
差异备份: - 它基于最新的完整数据备份。它仅收集在上次完整数据备份之后更改的数据。您可以定期备份数据库,而无需体验完整数据库备份的负担
。
Azure SQL数据库提供自动备份 。
完整的数据备份 - 每周;
差速器备份 - 每12-24小时一次;
交易日志备份 - 每5至10分钟一次。
尝试指定要获得字符串的模块。
例如com.example.module.r.string.home_activity_title
而不是r.string.home_activity_title
在Next.config.js
中禁用严格模式:
const nextConfig = {
reactStrictMode: false, // React Strict Mode is off
}
module.exports = nextConfig
这是我们在JavaScript的“奥秘”挣扎时面临的一个非常普遍的问题。让我尝试今天揭开这个谜。
让我们从一个简单的JavaScript函数开始:
function foo(){
// Do something
return 'wohoo';
}
let bar = foo(); // 'bar' is 'wohoo' here
这是一个简单的同步函数调用(在下一个代码的每行都“完成其作业”的“完成”),结果与预期的结果相同。
现在,让我们通过在函数中引入一点延迟来添加一些扭曲,以使所有代码都不是“完成”的。因此,它将模仿该功能的异步行为:
function foo(){
setTimeout( ()=> {
return 'wohoo';
}, 1000)
}
let bar = foo() // 'bar' is undefined here
因此您就去了;延迟刚刚打破了我们期望的功能!但是到底发生了什么?好吧,如果您查看代码,这实际上是合乎逻辑的。
函数foo()
,在执行后,返回什么都没有(因此返回的值是undefined
),但它确实启动了一个计时器,该计时器在1秒钟后执行函数以返回'哇。但是,如您所见,分配给bar的值是Foo()的立即返回的内容,即,即undefined
。
那么,我们如何解决这个问题
?
承诺实际上是关于它的含义:这意味着功能可以确保您提供将来的任何输出。因此,让我们在上面的小问题上查看它的行动:
function foo(){
return new Promise((resolve, reject) => { // I want foo() to PROMISE me something
setTimeout ( function(){
// Promise is RESOLVED, when the execution reaches this line of code
resolve('wohoo') // After 1 second, RESOLVE the promise with value 'wohoo'
}, 1000 )
})
}
let bar;
foo().then( res => {
bar = res;
console.log(bar) // Will print 'wohoo'
});
因此,摘要是 - 处理类似基于AJAX的呼叫等异步函数,您可以使用承诺来resolve> resolve
该值(哪个值(您打算返回)。因此,简而言之,您解决值,而不是返回,在异步函数中。
除了使用然后/catch
与Promises合作之外,更新(ASYNC/等待的承诺)
除了使用之外,还有另一种方法。这个想法是识别异步函数,然后等待承诺在移至下一行代码之前解决。它仍然只是引擎盖下的
承诺
,但采用不同的句法方法。为了使事情变得更清晰,您可以在下面找到一个比较:
然后/捕获版本:
function saveUsers(){
getUsers()
.then(users => {
saveSomewhere(users);
})
.catch(err => {
console.error(err);
})
}
async/等待版本:
async function saveUsers(){
try{
let users = await getUsers()
saveSomewhere(users);
}
catch(err){
console.error(err);
}
}
您可以使用filesystemwatcher:
$watcher = New-Object -TypeName System.IO.FileSystemWatcher -Property @{Path='c:\temp\lib'; Filter='*_output.txt'; NotifyFilter=[IO.NotifyFilters]::FileName, [IO.NotifyFilters]::LastWrite};
Register-ObjectEvent -InputObject $watcher -EventName Created -Action {Copy-Item $event.SourceEventArgs.FullPath $($event.SourceEventArgs.FullPath.Replace("output","input"))};
$watcher.EnableRaisingEvents = $true
这已经被问到很多次了,一般的想法是必然会在多用户环境中失败 - 一个博客系统听起来像是这种情况。
因此,最好的答案是:不要。考虑一种不同的方法。
将列 完全从您的表中 - 它不存储其他两个列category_id
(id,category)
不会存储的任何信息。
您的ID
是序列
列,并且已经以可靠的方式自动提示。
函数category_id
没有差距的类别
,使用row_number()
:
// variables object
const el = {
form: document.querySelector(".form"),
input: document.querySelector(".user-input"),
list: document.querySelector(".list"),
date: document.querySelector(".date"),
time: document.querySelector(".time"),
};
//local storage key
const STORAGE_KEY = "tasks-storage-key";
//Create ID
const createId = () =>
`${Math.floor(Math.random() * 10000)}${new Date().getTime()}`;
//variable of empty array that gets new task
let taskList = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "[]");
function makeNewTask() {
const data = {
id: createId(),
taskNew: el.input.value,
taskDate: el.date.value,
taskTime: el.time.value,
};
return data
}
//function that creates new tasks with date and time
function display() {
const tasks = document.createElement("div");
data = makeNewTask();
tasks.innerHTML = `
<div class="task-content">
<div class="task" data-id="${data.id}">
<div class="new-task-created">${data.taskNew}</div>
<label class="due-date">${data.taskDate}</label>
<label class="due-time">${data.taskTime}</label>
</div>
<div class="action-buttons">
<button onclick="editItem(event)" class="edit" data-id="${data.id}">Edit</button>
<button onclick="deleteItem(event)" class="delete" data-id="${data.id}">Delete</button>
<button onclick="completeItem(event)" class="complete" data-id="${data.id}">Complete</button>
</div>
</div>`;
taskList.push(tasks);
el.list.appendChild(tasks);
}
//event listner that listens for add button.
function addTask() {
display();
}
//function that stores task list.
function storeList() {
localStorage.setItem(STORAGE_KEY, JSON.stringify(taskList));
}
//function that removes task from array with delete button.
function deleteItem() {
let removeitem = document.querySelector(".task-content");
removeitem.parentNode.removeChild(removeitem);
localStorage.removeItem(STORAGE_KEY);
}
//function that removes stored task when deleted.
//function that that edits tasks with date and time.
function editItem(){
}
//function that that completes task.
function completeItem(event) {
const element = event.target.closest('.task-content')
console.log(element)
let taskItem = element.querySelector(".new-task-created");
let dateItem = element.querySelector(".due-date");
let timeItem = element.querySelector(".due-time");
// style..
taskItem.style.textDecoration = "line-through";
dateItem.style.textDecoration = "line-through";
timeItem.style.textDecoration = "line-through";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/main.css">
<script src="js/main.js" defer></script>
<title>To Do Application</title>
</head>
<body>
<div class="form">
<input class ="user-input" type="text">
<input class="date" type="date">
<input class="time" type="time">
<button onclick="addTask()" class="add" id="add">+</button>
</div>
<div class="list"></div>
<!--
<div class="task-content">
<div class="task" data-id="${id}">
<div class="new-task-created">${taskNew}</div>
<label class="due-date">${taskDate}</label>
<label class="due-time">${taskTime}</label>
</div>
<div class="atcion-buttons">
<button onclick="editItem()" class="edit" data-id="${id}">Edit</button>
<button onclick="deleteItem()" class="delete" data-id="${id}">Delete</button>
<button onclick="completeItem()" class="complete" data-id="${id}">Complete</button>
</div>
</div>
-->
</body>
</html>
patchQueryData
将“浸入式补丁”应用于缓存条目,而updateQueryData
允许您针对缓存条目运行一个函数,并且只需“更改”它。在内部,将创建一个补丁,然后调用UpdateQueryData
。因此,从本质上讲,PatchQueryData
是一个实现细节。它对大多数人来说不会有用,但是有些人可能会看到其中的好处,因此它也暴露了。
我认为,因为文本包含太空更新很奇怪。无论如何,如果您使用宽度:Max-Content;
在横幅类中,它不会振动怪异,并且宽度仍然仅包含在文本中。这仅起作用,因为该元素仅包含文本,如果您将其他div放入其中,则可能需要width:fit-content;
您的构造函数实现类型必须是所有声明的超级文档,如以下内容:
export interface ParamInterface {
a: number;
b: number;
c: number;
d?: number;
e?: number;
f?: number;
}
export class MyClass {
a: number;
b: number;
c: number;
d?: number;
e?: number;
f?: number;
constructor({ a, b, c, d, e, f }: ParamInterface);
constructor(a: number, b: number, c: number, d?: number, e?: number, f?: number);
constructor(...values: [ParamInterface] | [a: number, b: number, c: number, d?: number, e?: number, f?: number]) {
if (values.length == 1) {
const { a, b, c, d, e, f } = values[0];
// assign values
} else {
const [a, b, c, d, e, f] = values;
// assign values
}
}
}
在这里我们有两个构造函数声明:
constructor({ a, b, c, d, e, f }: ParamInterface);
constructor(a: number, b: number, c: number, d?: number, e?: number, f?: number);
一个实现:
constructor(...values: [ParamInterface] | [a: number, b: number, c: number, d?: number, e?: number, f?: number]) {
// ...
}
类型声明可以简化:
export interface ParamInterface {
a: number;
b: number;
c: number;
d?: number;
e?: number;
f?: number;
}
type TupleParameters = [a: number, b: number, c: number, d?: number, e?: number, f?: number];
export class MyClass {
// all fields
constructor({ a, b, c, d, e, f }: ParamInterface);
constructor(...values: TupleParameters);
constructor(...values: [ParamInterface] | TupleParameters) {
// unchanged
}
}
您是对的,您会收到错误,因为什么都没有添加到列表中。
这是因为在您的for循环中,您会迭代变量
i
,但您声明temp = p
。将此行更改为temp = i
。另外,您必须将
temp = p/10
更改为temp = temp/10
,就可以了。此外,您应该重写您的功能,以便即使列表中没有元素也没有异常。例如,您可以检查列表大小是否大于0,然后尝试访问其元素。
You are right, you get the error because nothing is added to the list.
This is because in your for loop, you iterate over the variable
i
, yet you declaretemp = p
. Change this line totemp = i
.Also, you have to change
temp=p/10
totemp=temp/10
and you're good to go.In addition, you should rewrite your function so that it does not throw an exception even if there is no element in the list. For example, you could check if the list size is greater than 0 and only then try to access its elements.
找不到最小结果