我正在使用Angular 4 with reactiveforms,momentjs和primeng calendar我正在使用setValue并尝试使用patchValue包含Date的reactiveForm字段.此日期已通过primeng日历创建.
purchaseDate: Sat Sep 02 2017 00:00:00 GMT+0100 (GMT Daylight Time)
我使用这个'日期'做了几件事,然后onSumbit的形式我把日期转换momentjs成一个干净的格式准备后端接受(即YYYY.MM.DD)使用.moment().format(....
但是,当我运行时,.setValue我得到以下控制台错误ERROR Missing number at position 0,无法弄清楚原因.
// convert the date
let newDate = moment(this.form.get('purchaseDate').value).format('YYYY.MM.DD');
// let newDate = moment(this.form.get('purchaseDate')).format('YYYY.MM.DD');
// with or without .value - display the same below (2017.09.01)
console.log(newDate); // 2017.09.01
this.form.get('purchaseDate').setValue(newDate);
// if I create a seperate (empty) reactiveForms field to test against
this.form.get('testField').setValue(newDate) // …Run Code Online (Sandbox Code Playgroud) 这是我想要制作的标准CSS,但是想要使用SASS Mixin来完成这项工作.
标准CSS
@-webkit-keyframes crank-up {
100% { -webkit-transform: rotate(360deg);}
}
@-moz-keyframes crank-up {
100% { -moz-transform: rotate(360deg);}
}
@-o-keyframes crank-up {
100% { -o-transform: rotate(360deg);}
}
keyframes crank-up {
100% { transform: rotate(360deg);}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用与下面的SASS关键帧相同的mixin,而不是按照需要进行编译,如下所示.
MIXIN
@mixin keyframes($name) {
@-webkit-keyframes #{$name} {
@content;
}
@-moz-keyframes #{$name} {
@content;
}
@-ms-keyframes #{$name} {
@content;
}
@keyframes #{$name} {
@content;
}
}
Run Code Online (Sandbox Code Playgroud)
只要没有关键帧包含需要供应商前缀的属性,上面就可以了.与transform属性一样,所有供应商前缀关键帧都应用了(在本例中)-webkit-前缀.例如:
SCSS
@include keyframes(crank-up) {
100% { -webkit-transform: rotate(360deg);}
}
Run Code Online (Sandbox Code Playgroud)
CSS
@-webkit-keyframes crank-up …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下js添加类或css样式但是出现控制台错误
var i = 0;
$(".question")[i].addClass("show");
Run Code Online (Sandbox Code Playgroud)
得到以下控制台日志错误:未捕获TypeError:对象#没有方法'addClass'
或/和
$(".question")[i].css("display", "block");
Run Code Online (Sandbox Code Playgroud)
得到以下控制台日志错误:未捕获TypeError:对象#没有方法'css'
用过的信息来自http://api.jquery.com/get/
编辑
如果摆脱变量i仍然无法工作,并使用数字0或1
我在angular 4项目中使用打字稿,并想使用moment-precise-range-plugin。
我已moment按照https://momentjs.com/docs/#/use-it/typescript/进行安装,但我想添加精确范围插件http://momentjs.com/docs/#/plugins/preciserange/。
用于Precisionrange插件的Node.js的安装位于https://codebox.org.uk/pages/moment-date-range-plugin并指定require('moment-precise-range-plugin');但未安装Typescript。
我已经尝试过import { Moment } from 'moment-precise-range-plugin';但出现以下打字稿错误
Could not find a declaration file for module 'moment-precise-range-plugin'. 'c:/Users/[UserName]/app/node_modules/moment-precise-range-plugin/moment-precise-range.js' implicitly has an 'any' type. Try npm install @types/moment-precise-range-plugin if it exists or add a new declaration (.d.ts) file containing declare module 'moment-precise-range-plugin';'
任何想法都非常欢迎!
javascript ×3
angular ×2
momentjs ×2
css3 ×1
ecmascript-6 ×1
jquery ×1
mixins ×1
primeng ×1
sass ×1
typeerror ×1
typescript ×1