我正在尝试使用 Hugo 尝试访问一个新站点,但在安装过程中被卡住了。我已经安装了 Homebrew,在运行该版本时,我得到以下信息:
~ % brew --version
Homebrew 2.7.2
Homebrew/homebrew-core (no git repository)
Homebrew/homebrew-cask (git revision b96680c; last commit 2021-01-07)
Run Code Online (Sandbox Code Playgroud)
当我跑 brew install hugo
我得到以下信息:
~ % brew install hugo
fatal: Could not resolve HEAD to a revision
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "hugo".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching …
Run Code Online (Sandbox Code Playgroud) 我陷入了十字路口观察者问题。使用document.querySelectorAll('.entry')
会抛出 TypeError:“未捕获 TypeError:无法在 'IntersectionObserver' 上执行 'observe':参数 1 不是 'Element' 类型。”
改变document.querySelectorAll('.entry');
以document.querySelector('.entry');
解决问题并且有效。
我究竟做错了什么?
基本的 HTML 结构:
<html>
<body>
<div id="content-container">
<div class="content">
<div class="entry">Some content here on each entry</div>
<div class="entry"></div>
<div class="entry"></div>
<div class="entry"></div>
<div class="entry"></div>
<div class="entry"></div>
</div>
</div>
</body
</html>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
const blog = document.querySelectorAll('.entry');
const options = {
root: null,
rootMargin: '0px',
};
const observer = new IntersectionObserver(function(entries, observer) {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
return;
}
else {
console.log(entry); …
Run Code Online (Sandbox Code Playgroud) 我尝试在某些类别的产品页面上的 WooCommerce 添加到购物车按钮下方添加一个 div。
我在这里有点不知所措。这段代码没有破坏任何东西,但文本没有显示。
我试过:.woocommerce div.product form.cart::after
,但这适用于所有产品。
这是 PHP 代码段:
function add_polarity_info() {
global $product;
if( is_product() && has_term( ['telecaster-pickups', 'strat-pickups', 'bass-pickups', 'p90-pickups', 'humbuckers', 'dynasonic-pickups', 'mini-humbuckers'], 'product_cat' )) {
echo 'If you are pairing with pickups from another manufacturer and are concerned about polarity and phasing, please let us know in the NOTES field on the checkout screen';
}};
add_action( 'woocommerce_after_add_to_cart_button', add_polarity_info() );
Run Code Online (Sandbox Code Playgroud)
有人可以指出我的代码的问题吗?
嘿,我正在尝试运行一个函数,并在用户选择美国以外的任何其他国家/地区时显示一条消息。但是,我陷入了困境,因为我什至无法选择框来记录国家/地区更改事件。这是我的代码:
function checkIfInternational(e) {
console.log(e);
}
const shipCountry = document.querySelector("#billing_country"); //Logs the select box
shipCountry.addEventListener("change", checkIfInternational); // listening for the change event
Run Code Online (Sandbox Code Playgroud)
关于为什么会发生这种情况有什么想法吗?Woocommerce 是否阻止 JS 在页面上运行或发生什么情况?
编辑:JS小提琴: https: //jsfiddle.net/suoc57mg/1/
我正在重建一个待办事项列表应用程序,并尝试使用面向对象编程,这对我来说是新的。我已经构建了任务部分,但我无法找到“删除”按钮。添加新任务时,右侧会显示一个很棒的字体图标。我正在尝试选择它们,但每次函数运行时我都会得到一个空的节点列表:
添加任务,然后检查控制台。您将看到一个空的节点列表。
现在,我正在尝试简化console.log
该元素。console.log(buttons)
每次该方法运行时我都会运行addTask()
。
这是完整的 JS:
const submit = document.querySelector("#commit-task"),
results = document.querySelector("#task-results"),
input = document.querySelector("#input-task"),
buttons = document.querySelectorAll(".fa-times"); // These are what I'm trying to select
class Task {
constructor(task) {
this.taskText = task;
}
addTask() {
const text = input.value;
ui.clearInput();
const taskBody = `<div class="task">
<span>${text}</span>
<span>
<i class="fas fa-check" style="color: green;"></i>
<i class="fas fa-times" style="color: red;"></I> //This is the element I'm trying to select
</span>
</div>`;
results.innerHTML …
Run Code Online (Sandbox Code Playgroud)