如何检查字符串是否包含javascript中的任何字母?
我目前使用它来检查字符串是否包含任何数字:
jQuery(function($){
$('body').on('blur change', '#billing_first_name', function(){
var wrapper = $(this).closest('.form-row');
// you do not have to removeClass() because Woo do it in checkout.js
if( /\d/.test( $(this).val() ) ) { // check if contains numbers
wrapper.addClass('woocommerce-invalid'); // error
} else {
wrapper.addClass('woocommerce-validated'); // success
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是我想让它看看它是否包含任何字母。
如何使用组件外部的函数更改 Popover 的内部状态:就像我在下面创建的 openPopover 函数一样。
const openPopover = () => {
setPopoverOpen(true) // Example..
}
<Popover>
{({open}: {open: boolean}) => {
// How do i change the open state here from outside the Popover.
return (
<>
<Popover.Button>
Test
</Popover.Button>
{open && (
<Popover.Panel static>
Test
</Popover.Panel>
)}
</>
)
}}
</Popover>
Run Code Online (Sandbox Code Playgroud) 每当有人将东西添加到购物车时,我就设法创建 onLineAdd toast 通知,但是,我似乎无法掌握如何显示产品信息并将其显示在 toast 中。
我正在寻找的是 onLineAdd 来触发一条通知:“XXX(带图片)已添加到购物车。” 这可能吗?
我的代码:
const open = useCallback(() => {
console.log("Opening product added popup, with image and title.")
}, []);
<ShopifyCartProvider
onLineAdd={open}
onCreate={open}>
{children}
</ShopifyCartProvider>
Run Code Online (Sandbox Code Playgroud)
它甚至在官方 Shopify 氢商店上实施:(尝试在此处添加一些东西到购物车) https://shopify.supply/products/entrepreneur-tee
javascript ×3
reactjs ×2
headless-ui ×1
jquery ×1
shopify ×1
tailwind-ui ×1
woocommerce ×1
wordpress ×1