我试图将一些数据发布到我的REST api,它有日期.现在,当我调试时,我的日期参数是一个JS Date对象,在我的时区中具有正确的日期:Tue Apr 04 2017 00:00:00 GMT+0530
在它离开我的代码后,我在网络选项卡中看到相同的内容,它将转换为UTC日期: "2017-04-03T18:30:00.000Z"
我搜索了解决方案,我需要在index.html中包含angular的locale文件,我做了:
<script type="text/javascript" src="resources/js/angular/angular-locale_en-in.js"></script>
Run Code Online (Sandbox Code Playgroud)
但它没有帮助.我已经看到了添加日期格式来过滤等问题的解决方案,但我想要一个全局解决方案.有帮助吗?谢谢 :)
我试图将我的-username-.github.io存储库发布到github页面,但我index.html的内部dist文件夹.
我无法使用,git subtree push --prefix dist origin gh-pages因为这适用于项目页面,而不是用户/组织页面.
我想要的只是,github将dist作为托管用户/组织页面的根目录.请帮忙.谢谢
PS:我不想做重定向黑客攻击.
你们如何在Vuetify中进行验证?我无法绕过非常冗长的验证语法。
根据Vuetify的文档,我正在使用Vuelidate,这是我必须实现一个简单的必填字段的方法:
脚本:
import { required } from 'vuelidate/lib/validators';
computed: {
userNameErrors() {
const errors = []
if (!this.$v.loginForm.userName.$dirty) {
return errors
}
!this.$v.loginForm.userName.required && errors.push('This field is required')
return errors
}
},
validations: {
loginForm: {
userName: {
required
}
}
}
Run Code Online (Sandbox Code Playgroud)
模板:
<v-text-field :label="Username"
prepend-icon="account_circle"
v-model="loginForm.userName"
:error-messages="userNameErrors"
@input="$v.loginForm.userName.$touch()"
@blur="$v.loginForm.userName.$touch()"
:required="true"></v-text-field>
Run Code Online (Sandbox Code Playgroud)
我觉得很冗长。我做事的方式可能是错误的,有人可以告诉您您是如何做到这种极简主义或简朴的吗?
PS我来自Angular1背景,并且ng消息非常酷而且简单!
我的应用程序根目录中有一个index.d.ts文件,其中声明了全局事物,例如全局模块。
所以我的index.d.ts看起来如下:
declare module 'moment';
Run Code Online (Sandbox Code Playgroud)
我可以导入moment任何.ts文件而不会出现任何错误。
现在,当我在index.d.ts文件中导入某些内容以进行更多声明时,就会出现问题。让我说如下:
import { MyService } from './path/to/file'; //line#1
declare module 'moment';
export interface SomeInterface {
name: string;
salary: number;
myService: MyService
}
Run Code Online (Sandbox Code Playgroud)
.ts现在我的文件中正在导入的任何导入moment都是错误的并抛出Cannot find module 'moment'.ts(2307)
我一发表评论line#1,moment导入就重新开始工作。
我在这里做错了什么?
我正在尝试调用一个函数,该函数Promise.resolve基于某些条件使用返回已解决的Promise 。
该函数的过度简化版本如下:
function fullFilledPromiseReturner(num: number) {
if (num > 5) {
return Promise.resolve(5);
} else {
return Promise.resolve();
}
}
fullFilledPromiseReturner(4).then(data => {
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
现在TypeScript不允许它通过编译器,并引发以下错误:
[ts] Cannot invoke an expression whose type lacks a call signature. Type '(<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResu...' has no compatible call signatures.
我究竟做错了什么?
当我尝试使用我的自定义mixin扩展lodash时,我在使用Lodash时遇到问题.
我不成功的尝试:
假设我使用mixins为lodash添加一个新函数,如下所示:
//lodashMixins.ts
import * as _ from "lodash";
_.mixin({
swap
});
function swap(array: Array<any>, index1: number, index2: number) {
let temp = array[index1];
array[index1] = array[index2];
array[index2] = temp;
return array;
}
Run Code Online (Sandbox Code Playgroud)
如果我在其他文件中,该功能swap不可用._import _ from "lodash";
部分成功的尝试:
于是我找了帮助,人们提出来extend _.LoDashStatic,然后导出_作为新的扩展interface.
然后我做了以下事情:
//lodashMixins.ts
import * as _ from "lodash";
interface LodashExtended extends _.LoDashStatic {
swap(array: Array<any>, index1: number, index2: number): Array<any>;
}
_.mixin({
swap
});
function swap(array: Array<any>, …Run Code Online (Sandbox Code Playgroud) 我一直在制作简单的javafx 2 gui应用程序,发现一旦textfield获得焦点,javafx 2的textfield中的prompttext就会隐藏.
这不是一些更新的方式.在此更新之前,文本字段显示了提示文本,直到键入一些文本为止.
这不好,真的需要一个解决方法.
javascript ×5
typescript ×3
angularjs ×1
build ×1
chaining ×1
deployment ×1
es6-promise ×1
focus ×1
github ×1
github-pages ×1
gulp ×1
javafx-2 ×1
lodash ×1
mixins ×1
promise ×1
text ×1
textfield ×1
timezone ×1
types ×1
vue.js ×1
vuejs2 ×1
vuelidate ×1
vuetify.js ×1