我想从字符串中删除所有特殊字符(数字除外).我已经能够做到这一点
var name = name.replace(/[^a-zA-Z ]/, "");
Run Code Online (Sandbox Code Playgroud)
但它似乎正在移除第一个数字并留下所有其他数字.
例如:
name = "collection1234"; //=> collection234
Run Code Online (Sandbox Code Playgroud)
要么
name = "1234567"; //=> 234567
Run Code Online (Sandbox Code Playgroud) 我试图从json数组中删除一段数据.例如,我有这个数组
var favorites = {
"userID": "12345678",
"favorites": [
{ "name" : "My Favorites",
"id" : "87654321",
"items":
[
{
"productID": "11234567",
"added": "TIMESTAMP",
"title": "Project",
"type": "Weekend Project",
"imageURL": "1"
},
{
"productID": "11223456",
"added": "TIMESTAMP",
"title": "Bathroom",
"type": "Weekend Project",
"imageURL": "2"
},
{
"productID": "11223345",
"added": "TIMESTAMP",
"title": "Curves",
"type": "Collections",
"imageURL": "3"
}
]
},
{ "name" : "Bathroom",
"id" : "87654323",
"items":
[
{
"productID": "11122224",
"added": "TIMESTAMP",
"title": "Project",
"type": "Weekend Project",
"imageURL": "1" …Run Code Online (Sandbox Code Playgroud) 我想知道是否有人可以给我一个基本的细分这些图标是如何制作的.我看到它们是SVG并使用Raphael js动画,但画布上是否绘制了每个图标?或者是图标实际的svg文件,每个只用raphael.js独立动画?
我有一个我想要使用自己的图标,看看我是否可以按照自己的方式设置动画,类似于那些图标.有没有人有关于这种技术的想法或教程?我一直在阅读raphael js,但看起来它主要用于绘制SVG然后制作动画,所以我不是100%.
我一直试图通过检查员阅读,但我无法真正理解每个动画的作用(它如何知道图标的哪个部分要操纵等?)
谢谢任何人!
我愚蠢地点击了我的公钥所在的SSH文件夹里面的'Create Repo Here'.现在我的所有文件夹旁边都有这个小蓝色问号,我无法再成功克隆回购.我每次都会收到错误.
我该怎么办?
我有一组测试在本地运行良好,但是当它们在 CircleCI 构建内部运行时,拦截命令无法按预期工作。检查 Cypress 记录表明从未提出任何请求。
测试代码:
before( () => {
cy.intercept( 'GET', '**wp-json/wp/v2/pages?context=edit&status%5B0%5D=publish**' ).as( 'getPages' );
cy.intercept( 'GET', '**wp-json/wp/v2/posts?context=edit&status%5B0%5D=publish**' ).as( 'getPosts' );
openComplementaryArea( 'Site contents' );
// Make sure our data has loaded.
cy.wait( '@getPages' ).its( 'response.statusCode' ).should( 'eq', 200 );
cy.wait( '@getPosts' ).its( 'response.statusCode' ).should( 'eq', 200 );
} );
Run Code Online (Sandbox Code Playgroud)
我尝试增加拦截命令等待的时间,但请求仍然无法通过。
有什么想法为什么这可以在本地运行,但不能在 CircleCI 构建中运行?这几天我一直在胡思乱想,尝试了我能想到的一切。
我已经使用 create-react-app 创建了一个新的 React 应用程序,并尝试构建文件,但我现在收到所有这些错误。我已经尝试调试这个问题一个小时了,但几乎没有取得任何进展。此错误来自许多依赖项。
这是什么错误,如何修复它?现在这是一个非常简单的项目,所以我不完全确定为什么会出现这个错误。
WARNING in ./node_modules/react-double-scrollbar/dist/DoubleScrollbar.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/localmachine/Desktop/temp/app/node_modules/react-double-scrollbar/dist/DoubleScrollbar.js.map' file: Error: ENOENT: no such file or directory, open '/Users/localmachine/Desktop/temp/app/node_modules/react-double-scrollbar/dist/DoubleScrollbar.js.map'
@ ./node_modules/material-table/dist/material-table.js 42:51-84
@ ./node_modules/material-table/dist/index.js 29:44-71
@ ./src/components/countries-data-table/index.js 5:0-43 97:32-45
@ ./src/App.js 9:0-67 112:39-57
@ ./src/index.js 7:0-24 10:38-41
Run Code Online (Sandbox Code Playgroud) 我试图将纯文本电子邮件地址转换为表格内的可点击邮件链接.
我有以下功能,将找到的链接转换为mailto链接,但它似乎只适用于第一个找到的链接.任何后续链接(第2次,第3次出现等)仍保留为纯文本链接.我似乎无法弄清楚我可能做错了什么.任何帮助将非常感激!
代码:
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<div class='filter-email-box'>
<div>This is a sample text which contains john@gmail.com </div>
<div>This text contains two emails adam@example.com and paul@example.com </div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
$(".filter-email-box div").filter(function(){
var html = $(this).html();
var emailPattern = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;
var matched_str = $(this).html().match(emailPattern);
if(matched_str){
$(this).html(html.replace(emailPattern,"<a href='mailto:"+matched_str+"'>"+matched_str+"</a>"));
return $(this)
}
})
Run Code Online (Sandbox Code Playgroud)
以下是我设置的小提琴:http: //jsfiddle.net/z6LF5/
我正在建立一个使用同位素来过滤页面上的帖子的网站.
我正在使用高级自定义字段(http://www.advancedcustomfields.com/),并创建了一个用户可以为"项目难度"设置字段的部分.
我试图遍历所有可能的选择,以创建用户可以单击以进行排序的链接列表(使用同位素).我已成功使用'标签',但我不想用难度级别标记每个项目,我希望用户在ACF下拉列表中创建帖子时选择它.
为了成功获取并显示链接形式的标签列表,我使用了以下代码:
<?php
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a data-filter=.{$tag->name} title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
?>
Run Code Online (Sandbox Code Playgroud)
现在我尝试改变它,使用这样的代码使ACF工作:
<?php
$fields = get_fields();
$html = '<div class="post_tags">';
foreach ( $fields as $field ) {
$tag_link = get_fields( $field->task_difficulty );
$html .= "<a data-filter=.{$field->name} title='{$field->name} Tag' class='{$field->slug}'>";
$html .= "{$field->name}</a>";
}
$html .= '</div>';
echo $html; …Run Code Online (Sandbox Code Playgroud) 我在页面上有一些链接都具有相同的类"expand-content-link",这些链接都直接在div上面,其中包含一些内容,设置为"display:none;" (具有相同的类"隐藏内容").
我希望能够单击该链接,只有链接下方的div切换为可见.
HTML
<div class="content-holder">
<a href="#" class="expand-content-link">Expand Content 1</a>
<div class="hidden-content">Bunch of hidden content and stuff here</div>
</div>
<div class="content-holder">
<a href="#" class="expand-content-link">Expand Content 2</a>
<div class="hidden-content">Bunch of hidden content for div 2</div>
</div>
<div class="content-holder">
<a href="#" class="expand-content-link">Expand Content 3</a>
<div class="hidden-content">Bunch of hidden content for div 3</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我的javascript如下,但它目前使用"hidden-content"类扩展了所有内容(原因很明显),我无法弄清楚如何操作代码,因此它只显示它所需的内容.
JavaScript的:
<script>
jQuery(document).ready(function() {
jQuery(".expand-content-link").click(function() {
jQuery(".content-holder").find(".hidden-content", this).toggle();
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
JSFIDDLE DEMO:http: //jsfiddle.net/PsAh9/
我通常使用WordPress,但刚刚为客户端完成了一个项目,该客户端是一个静态HTML页面,每页包含8页和~2个图像.使用WordPress我会使用w3总cachce,cloudflare,photon或通过wp引擎的解决方案.
我一直在做研究,发现了一些关于元标记和操作.htaccess文件的解决方案.我读过,meta标签路由不是一个合理的解决方案,因为它没有正确验证HTML5.(这特别指的是设置没有缓存,但同样的想法)
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
Run Code Online (Sandbox Code Playgroud)
参考这里: 使用<meta>标签关闭所有浏览器的缓存?
我在这里也读了一下:http: //www.metatags.info/meta_http_equiv_cache_control
使用这样的东西:
<meta http-equiv="Cache-control" content="public">
<meta http-equiv="Cache-control" content="private">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache-control" content="no-store">
Run Code Online (Sandbox Code Playgroud)
但我不确定它们是如何工作的,哪些是正确的.有人能指出我正确的方向吗?谢谢!
我正在编写一些允许用户上传.zip文件的代码.当他们上传文件时,.zip会移动到服务器上的正确位置.一切正常.
我创建了一个按钮,允许用户删除他们上传的文件.当按钮单击时,我使用ajax来调用包含unlink();代码的.php文件.
Ajax Call
function delete_custom_pack() {
var phpfilepath = '/path/to/php/file/';
//console.log( phpfilepath );
jQuery.ajax({
method: 'get',
url: phpfilepath ,
success: function() {
alert("successfully got file");
},
error: function() {
alert("error getting file");
}
});
}
Run Code Online (Sandbox Code Playgroud)
PHP文件
<?php
$filename = 'http://www.some-site/wp-content/uploads/custom-folder/custom-pack/test.zip';
unlink($filename);
?>
Run Code Online (Sandbox Code Playgroud)
我收到"成功获取文件"的警报,但该文件永远不会在服务器上取消链接.它仍然驻留在目录中.成功的电话只是让我知道它成功获得了php文件.在unlink($file);我的PHP文件里似乎并没有被执行.
我已经设置了一个自定义帖子类型,可以管理网站前端的帖子。在前端,用户可以选择编辑或删除帖子。
当用户单击删除时,我运行 wp_delete_post() 函数,将帖子发送到垃圾箱。我不希望帖子绕过垃圾箱,我实际上希望将帖子发送到垃圾箱。
wp_delete_post 的第二个参数是一个布尔值 true/false ,它应该指示天气或不绕过垃圾箱。
第一个是您要删除的帖子的 ID。
http://codex.wordpress.org/Function_Reference/wp_delete_post
这是我的功能:
wp_delete_post( $cpt_id, false );
如您所见,我已将第二个参数设置为 false,但它仍会绕过垃圾箱并从服务器中删除。
这是我应该向核心报告的错误,还是我遗漏了一些简单的东西?
谢谢!