我正在使用Asp.Net Mvc3和不引人注目的jquery验证.我想让我的日期验证本地化,我的意思是,jquery验证我的日期是MM/dd/yyyy,但我希望它是dd/MM/yyyy.
我正在尝试使用jQuery Globalize插件(http://github.com/jquery/globalize).我添加了对脚本globalize.js和globalize.culture.pt-BR.js的引用,当我的页面加载时,我正在运行以下脚本:
(function() {
$(function() {
$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
Globalize.culture("pt-BR");
});
}).call(this);
Run Code Online (Sandbox Code Playgroud)
jQuery UI插件作为魅力,但验证不起作用.我还缺少什么?
编辑:
使用下面答案中的链接,我使用Globalize插件解决了问题:
当然,我必须在页面中添加对Globalize插件的引用,以及对我想要使用的文化的引用(所有这些都在插件的站点上提供).之后只是一小段JavaScript代码.
Globalize.culture("pt-BR");
$.validator.methods.date = function(value, element) {
return this.optional(element) || Globalize.parseDate(value);
};
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用包含css文件的react组件.我像往常一样要求组件:
var Select = require('react-select');
Run Code Online (Sandbox Code Playgroud)
我想知道如何才能要求组件所需的css.
我已经尝试过了:
require('react-select/dist/react-select.css');
Run Code Online (Sandbox Code Playgroud)
还有这个:
require('react-select.css');
Run Code Online (Sandbox Code Playgroud)
没有人奏效.
我试图存根此对象中使用的mongoose依赖项:
var Page = function(db) {
var mongoose = db || require('mongoose');
if(!this instanceof Page) {
return new Page(db);
}
function save(params) {
var PageSchema = mongoose.model('Page');
var pageModel = new PageSchema({
...
});
pageModel.save();
}
Page.prototype.save = save;
}
module.exports = Page;
Run Code Online (Sandbox Code Playgroud)
使用这个问题的答案,我试过这样做:
mongoose = require 'mongoose'
sinon.stub mongoose.Model, 'save'
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:
TypeError:尝试将undefined属性保存为函数
我也试过这个:
sinon.stub PageSchema.prototype, 'save'
Run Code Online (Sandbox Code Playgroud)
然后我得到了错误:
TypeError:应该包装对象的属性
有人能帮忙吗?我究竟做错了什么?
我正在尝试为我们的项目增加Sinon类型定义,这里是如何Sinon.d.ts定义的
declare module 'sinon' {
module Sinon {
interface SinonStub extends SinonSpy {
...
}
interface SinonStatic { ... }
...
}
var Sinon: Sinon.SinonStatic;
export = Sinon;
}
Run Code Online (Sandbox Code Playgroud)
我有一个definitions.d.ts我在我的项目中使用的任何自定义定义.这是我试图这样做的方式:
declare module 'sinon' {
module Sinon {
interface SinonPromise {
resolves(value?: any): void;
rejects(value?: any): void;
}
interface SinonStub {
returnsPromise(): SinonPromise;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是编译器无法识别新returnsPromise的SinonStub界面,也不承认新的SinonPromise类型.
这个定义有什么问题?
我正试图用zipAlbacore中的任务压缩,但是我收到了一个错误.这是IronRuby的问题吗?
task :publish => :build do
Rake::Task[:service].invoke
Rake::Task[:site].invoke
Rake::Task[:zip_svc].invoke
end
zip :zip_svc do |zip|
zip.directories_to_zip 'publish'
zip.output_file = 'Svc.zip'
zip.output_path = File.dirname(__FILE__)
end
Run Code Online (Sandbox Code Playgroud)
错误>
** Invoke zip_svc (first_time)
** Execute zip_svc
rake aborted!
wrong number of arguments (1 for 2)
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1113:in `<<'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1062:in `<<'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/ioextras.rb:125:in `write'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/ioextras.rb:9:in `copy_stream'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:832:in `write_to_zip_output_stream'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:772:in `get_input_stream'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:832:in `write_to_zip_output_stream'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1515:in `commit'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1153:in `each'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1153:in `each'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1515:in `commit'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:963:in `open'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1512:in `commit'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1601:in `on_success_replace'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1510:in `commit'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1525:in `close'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/rubyzip-0.9.4/lib/zip/zip.rb:1415:in `open'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/albacore-0.2.5/lib/albacore/zipdirectory.rb:28:in `execute'
c:/IronRuby/Lib/ruby/gems/1.9.1/gems/albacore-0.2.5/lib/albacore/support/createtask.rb:24:in `zip' …Run Code Online (Sandbox Code Playgroud) 我不时地在git存储库中取消跟踪文件,并希望将其删除。
是否有使用git或bash甚至另一种方法的简便方法?
假设我有这样一个类:
import {bindable} from 'aurelia-framework';
export default class MyClass {
@bindable text = null;
bind() {
this.message = `Message: ${this.text}`;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的测试代码中,我有以下代码:
import MyClass from '../../src/myclass';
describe('MyClass', () => {
let sut;
beforeEach(() => sut = new MyClass());
describe('bind', () => {
beforeEach(() => {
sut.text = "my text";
sut.bind();
});
it('should have a message', () => {
expect(sut.message).toBe('Message: my text');
});
});
});
Run Code Online (Sandbox Code Playgroud)
当我运行此测试时,我抛出以下错误:
TypeError:无法在MyClass读取getObserver(C:/Users/vinte/Documents/projects/mealcal/jspm_packages/github/aurelia/templating@0.15.1/aurelia-templating.js:2571:40)中未定义的属性'getOrCreateObserversLookup'在Object中.descriptor.set [as text](C:/Users/vinte/Documents/projects/mealcal/jspm_packages/github/aurelia/templating@0.15.1/aurelia-templating.js:2628:9).(C:/Users/vinte/Documents/projects/mealcal/test/unit/myclass.spec.js:26:16)
我想基于绑定到可绑定字段的值来测试bind方法是否具有正确的行为.
你是怎样做的?
我正在尝试从 jasmine 合并 Matchers 界面。该接口在 jasmine 命名空间内声明。
我创建了 .d.ts 文件并添加了以下内容:
declare namespace jasmine {
interface Matchers {
toBeSuccessful(): boolean;
}
}
Run Code Online (Sandbox Code Playgroud)
这有效,但如果我尝试向 .d.ts 文件添加导入语句,则它不起作用。该toBeSuccessful功能无法识别。
我还尝试在我的函数实现中添加这部分代码,而不是在 d.ts 文件中,但是,命名空间的其他成员不再可用,例如在此代码中:
class ToBeSuccessfulMatcher implements jasmine.CustomMatcher {
compare<T>(actual: Result<T>): jasmine.CustomMatcherResult {
}
}
Run Code Online (Sandbox Code Playgroud)
接口 CustomMatcher 和 CustomMatcherResult 不再可用。
我错过了什么?
我正在尝试运行 Prettier CLI 工具,我想做的是一次针对多个文件运行它,这可能吗?
我知道我们可以使用 glob 模式,但这些文件不容易与模式匹配。因为我正在尝试针对预提交挂钩中的暂存文件运行 CLI 工具。
所以我希望做一些类似的事情: prettier --write "file.js, src/file2.js, src/somepath/file2.js"
那可能吗?
我正在创建一个用Umbraco 6制作的博客,我想自定义网址.
当我创建博客帖子时,帖子按年/月/日结构组织,帖子的网址为blog.com/2013/2/19/title.aspx.
我想保留文件夹组织,但我想将网址更改为blog.com/title.aspx
那可能吗?我怎样才能做到这一点?
我正在尝试确定表单是否有效使用角度.
我有一个这样的表格:
<form name="form" novalidate>
<p>
<label>Number: </label>
<input type="number" min="0" max="10" ng-model="test.number" required />
</p>
<p>
<label>Name: </label>
<input type="text" ng-model="test.name" required />
</p>
<button ng-click="sendTest(test)">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
并且,在sendTest函数上我做了:
angular.module('demo', [
]).controller('MainCtrl', function($scope){
$scope.test = {
name: 'das'
};
$scope.sendTest = function(test) {
console.log(form.$valid);
console.log(test.$valid);
}
});
Run Code Online (Sandbox Code Playgroud)
问题是形式.$ valid和test.$ valid都是未定义的.我尝试按照以下示例执行此操作:
http://dailyjs.com/2013/06/06/angularjs-7/ http://www.youtube.com/watch?v=J82OD76QhPo
以下是此演示的完整代码:http: //plnkr.co/edit/l0E62KPJu4Z2r15VNjJq