小编use*_*232的帖子

Js es6类构造函数在构造函数实例化之前运行

我有一个es6类实例化一个函数调用的变量,但问题是该函数似乎在构造函数实例化之前运行并抛出一个错误:

  constructor() {
    this.userSelections = {
      types    : this.getTypes(),
      providers: this.getProvider()
    } 
  }

 getProvider() {
    // here its throw error that this.userSelections is undefined
    var activeType = this.userSelections.types.some(( type ) => {
      return type.active;
    });

  }
Run Code Online (Sandbox Code Playgroud)

什么是问题,我怎么能处理这种情况?

javascript ecmascript-6 babeljs

5
推荐指数
1
解决办法
1114
查看次数

Typescript导入带有ECMAscript 6语法的node_modules

我从npm 安装了库lodash,现在我想将它导入我的文件,如下所示:

import _ from 'lodash';
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

错误TS1192:模块'"lodash"'没有默认导出.

为什么我会收到此错误?以及如何使用ECMAscript6的新导入语法导入不是.ts文件的node_modules

javascript typescript

3
推荐指数
1
解决办法
5732
查看次数

CSS flex-wrap属性:理解数学

在以下示例中,我在flex-basis属性中使用百分比值.是什么让浏览器决定何时开始破坏行?

body {
  margin: 100px;
}

* {
 box-sizing: border-box;
}
section {
  display: flex;
  flex-wrap: wrap;
}
div {
  border: 1px solid;
  padding: 1rem;
  flex: 1 0 10%;
}
Run Code Online (Sandbox Code Playgroud)
<section>

  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
</section>
Run Code Online (Sandbox Code Playgroud)

html css css3 flexbox

3
推荐指数
1
解决办法
342
查看次数

回到初始风格时的Css动画

我在图像上有缩放动画,但是当动画完成并回到初始大小时没有动画,我怎样才能在回到初始值时强制动画?

http://jsbin.com/tijapahuwi/edit?html,css,output

@keyframes scaleImg {
    from {
        transform: scale(0.8);
    }
    to {
        transform: scale(1);
    }
}

img { 
   transform: scale(0.8);
   animation: scaleImg 1.5s;
   animation-direction: alternate;
}



<img src="http://lorempixel.com/400/200/sports/" alt="">
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery animation

0
推荐指数
1
解决办法
546
查看次数

标签 统计

javascript ×3

css ×2

html ×2

animation ×1

babeljs ×1

css3 ×1

ecmascript-6 ×1

flexbox ×1

jquery ×1

typescript ×1