草庐IT

save_and_new

全部标签

javascript - ((?:[^\"])*) and ([^\"]*) 之间的正则表达式差异

这个正则表达式是可替换的有什么区别?((?:[^\"])*)([^\"]*)这个问题的背景:javascript所见即所得编辑器(tinymce)无法解析我的html代码在Firefox(23.0.1和25.0a2)中,但在Chrome中工作。我发现正则表达式是罪魁祸首:attrRegExp=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g;我修改,替换((?:[^\"])*)与([^\"]*)和((?:[^\'])*)与([^\']*)生成的正则表达式在我的测试用例的两个浏

javascript - 用户界面路由器 : open modal and pass parent scope parameters to it

我正在使用这个FAQ条目在某个状态的子状态中打开模式对话框:https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state我的代码如下。当我打开模式对话框时,我需要访问父状态范围的属性。这可能吗?plnkr:http://plnkr.co/edit/knY87n.state('edit',{url:'/{id:[0-9a-f]+}',views:{'@':{templateUrl:'views/edit.html',c

javascript - ES6 模块 : Exporting and importing performance differences

我的vue项目中有一些组件。我不喜欢importloaderfrom'@/components/someComponent1/someComponent1.vue';因为要写的东西很多而且我必须为每个组件重复一遍。所以我为components文件夹写了一个index.js:export{defaultassomeComponent1}from'./someComponent1/someComponent1.vue';export{defaultassomeComponent2}from'./someComponent2/someComponent2.vue';...这将允许我在一行中导

javascript - 云函数 : How to copy Firestore Collection to a new document?

我想在发生事件时使用CloudFunctions在Firestore中制作一个集合的副本我已经有了迭代集合并复制每个文档的代码constfirestore=admin.firestore()firestore.collection("products").get().then(query=>{query.forEach(function(doc){varpromise=firestore.collection(uid).doc(doc.data().barcode).set(doc.data());});});有更短的版本吗?一次复制整个集合? 最佳答案

javascript - 为什么是 { : y = 1 } = { b: 2 } valid and { a: 1 } = { b: 2 } a SyntaxError?

我不明白为什么这两个JS表达式不等价为了在JS上做得更好,我正在尝试一些javascript表达式。这是我的最新发现:{a:y=1}={b:2}//{b:2}{a:1}={b:2}//UncaughtSyntaxError:Unexpectedtoken=谁能帮我理解一下? 最佳答案 首先,这不是destructuringassignmentswithoutdeclarations的正确语法.Theparentheses(...)aroundtheassignmentstatementarerequiredwhenusingobje

javascript - 范围对象 : differences between Webkit and Mozilla based browsers

目前,我在为基于Mozilla和Webkit的浏览器编写抽象层以使用DOM范围对象(获取和处理用户选择)时遇到了一些麻烦。我也尝试过查看像Rangy这样的框架,但这对我的任务来说似乎太复杂了(我不知道在代码中的确切位置可以找到我需要的信息。如果有人能给我提示,我将不胜感激!)。我想要的就是这样:取回对选择开始的文本节点的引用及其偏移量取回对选择结束的文本节点的引用及其偏移量到目前为止,我的层看起来像这样:varSEL_ABSTR={get_selection:function(window_object){returnwindow_object.getSelection();},get

javascript - 在 "var new_function = function name(){};"中用 javascript 定义函数名有什么好处吗?

当我运行一个程序来更改我的javascript代码的某些部分时,它在将var声明为函数时出现错误,如下所示:varsome_function=functionname(args){//dostuff};代码本身有效,但我只是想知道是否可以删除我发现的所有函数的“名称”(因为它不会在分析我的javascript的其他问题中破坏它)或者它是否可以它可能有我看不到的任何用途。删除“名称”:varnew_function=function(){/*dostuff*/};注意:它第一次出现的原始文件在jquery-1.6.4.js中在:jQuerySub.fn.init=functioninit

javascript - 在Javascript中, 'Object.create'和 'new'的区别

我认为差异已经在我脑海中闪过,但我只是想确定一下。在DouglasCrockford页面上PrototypalInheritanceinJavaScript,他说Inaprototypalsystem,objectsinheritfromobjects.JavaScript,however,lacksanoperatorthatperformsthatoperation.Insteadithasanewoperator,suchthatnewf()producesanewobjectthatinheritsfromf.prototype.我不太明白他在那句话中想说什么,所以我进行了一些

javascript - node js 和 new 在使用 require 时

我一直在尝试整理node.js中其他js文件的包含。我已经阅读了所有关于require函数和其他替代方法的信息,并决定使用require函数(因为代码只会在node.js上使用,而不是在浏览器中使用)。在我的代码中,我使用原型(prototype)来创建一个“对象”,我稍后希望创建一个实例。为了让它工作,我一直在编写如下代码(我们称之为vehicle.js):varutil=require('util');varEventEmitter=require('events').EventEmitter;module.exports=Vehicle;util.inherits(Vehicle

javascript : how to distinguish between selected element list and form

这是脚本:http://jsbin.com/itusut/6/edit你好,我有功能:functionon(t,e,f){if(e.length){varl=e.length,n=0;for(;n如果我们这样做varhandle=document.getElementsByClassName('some-class');然后handle是一个节点列表。如果我们这样做varhandle=document.getElementById('an-id');然后handle是单节点。问题是,当我选择时它返回array而不是单个元素。所以,我的on功能失败。函数使用elm.length筛选。一切