小编Mat*_*ood的帖子

Bower在运行grunt发球后抛出jquery"未注入"警告

我最近不得不克隆一个项目并重建bower包.我相信jQuery已更新,现在正在发出警告:

警告:
Please go take a look in "app/bower_components/jquery" for the file you need, then manually include it in your file.

我做到了这一点.并且每个标志都正常工作.但是,每次我grunt serve警告仍然被抛出?

jquery was not injected in your file.
Run Code Online (Sandbox Code Playgroud)

如何删除此错误?并且这会导致一个笨拙的构建错误吗?我确信这个警告是无害的,但看到它真的很难过.

主要.bower.json

{
  "name": "jordan",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.6",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-resource": "1.2.6",
    "angular-cookies": "1.2.6",
    "angular-sanitize": "1.2.6",
    "angular-route": "1.2.6",
    "jquery-ui": "~1.10.3"
  },
  "devDependencies": {
    "angular-mocks": "1.2.6",
    "angular-scenario": "1.2.6"
  }
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

.bower.json for jquery

{
  "name": "jquery",
  "version": "2.1.0",
  "ignore": [
    "**/.*",
    "build",
    "speed",
    "test", …
Run Code Online (Sandbox Code Playgroud)

javascript jquery json yeoman bower

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

如何防止滚动效果使我的屏幕在滚动时闪烁

使用scrollTo函数时,使用chrome和ff到目前为止已经造成了一个令人讨厌的故障?有谁知道如何防止这种情况发生?
现场代码

HTML

 <ul class="wrapper">
    <li class="listItem"><img src="asset/img/logo.png" ></li>
    <li class="listItem"><a onclick="scrollTo('#container',500);" href="#">Company</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('.flexslider-container',500);" href="#">Service</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('#map',500);" href="#">Map</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('#footer',500);" href="#">Contact</a></li>
    <li class="listItem">
      <p>250-610-9100</p>
    </li>
  </ul>
Run Code Online (Sandbox Code Playgroud)

脚本

<script type="text/javascript">
function scrollTo(o, s) {
    var d = $(o).offset().top;
    $("html:not(:animated),body:not(:animated)").animate({
        scrollTop: d
    }, s);
}
</script>
Run Code Online (Sandbox Code Playgroud)

html css jquery

2
推荐指数
1
解决办法
1681
查看次数

如何使画布轮廓在悬浮发光时成为透明的png

是否可以自动给图像赋予发光效果,例如使用画布?

jsfiddle

canvas标签必须省略透明

透明iphonev

并使其具有外部辉光?

外发光

<canvas id="canvas" width=960 height=960></canvas>
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery canvas

2
推荐指数
1
解决办法
2127
查看次数

为什么http.Request参数必须是指针?

package main

import (
    "net/http"
)

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
        w.Write([]byte("hello world"))
    })
    http.ListenAndServe(":8000", nil)
}
Run Code Online (Sandbox Code Playgroud)

如果我删除*in http.Request:

github.com/creating_web_app_go/main.go:8:不能在http.HandleFunc的参数中使用func文字(类型为func(http.ResponseWriter,http.Request))作为类型func(http.ResponseWriter,*http.Request)

我对Go和指针都很新.

所以问题是,为什么必须http.Request是指针而不是func literal?任何人都可以用最简单的方式解释这一点,也许可以参考源代码?

pointers go

2
推荐指数
1
解决办法
1095
查看次数

如何从 JavaScript 中的字符串数组中删除字符模式?

实时代码

我有一个字符串数组。每个字符串代表一条路径。我需要删除该路径中区域设置代码之前的所有内容。我希望它返回一组新的干净路径。

问题: 如何编写和使用从原始字符串中删除所有语言环境的模式arr.filter()match()

代码:

var thingy = ['thing/all-br/home/gosh-1.png','thing/ar_all/about/100_gosh.png','thing/br-pt/anything/a_noway.jpg'];
var reggy = new RegExp('/[a-z]{2}-[a-z]{2}|[a-z]{2}_[a-z]{2}/g');


var newThing = thingy.filter(function(item){
       return result = item.match(reggy);
    });
Run Code Online (Sandbox Code Playgroud)

最后,我想过滤原始数组thingynewThing输出应如下所示:

console.log(newThing);
// ['home/gosh1.png','about/gosh.png','place/1noway.jpg']
Run Code Online (Sandbox Code Playgroud)

javascript regex arrays substring filter

2
推荐指数
1
解决办法
1276
查看次数

一个$ http请求到api成功后,Angular $ q库链接方法?

我以前从未写过承诺,但我觉得这段代码传达了我的意图.

问题:在我的http请求完成,转换并返回之后, 如何在init块中异步触发matchData()和触发countData().

 function getLangData(langCode) {

    var url = "https://translate.google.com/translate_a/l?cb=JSON_CALLBACK";
      return $q(function(resolve, reject) {    
      $http.jsonp(url, {
        params: {...}
      })
        .success(function (translateAPIData) {
                 return translateAPIData.map(function(){...});
          });
        });

      });
  }

function init() {
  var promise = getLangData(languageCode);
  promise.then(function(mappedData) {
     matchData(mappedData);
  });
  promise.then(function(mappedData) {
     countData(mappedData);
  });  

  }); 
}
Run Code Online (Sandbox Code Playgroud)

javascript ajax asynchronous angularjs angular-promise

2
推荐指数
1
解决办法
76
查看次数

在以下'then'函数中取消$ timeout是否有效?

我一直这样做,我不太确定它有效.如果有,我该如何检查?如果它没有更好的方法在完成后取消超时?

var delay = $timeout(function() {
      for (i = 0; i < allHighlightedEls.length; i += 1) {
       //... some transformations
      }
    }, 1000)
      .then(function() {
        $timeout.cancel(delay);
      });
Run Code Online (Sandbox Code Playgroud)

javascript settimeout angularjs angular-timer

2
推荐指数
1
解决办法
44
查看次数

如何使用@HostListener传递window:scroll目标以触发Observable.fromEvent()订阅?

我想保留与@HostListner该事件中使用的相似的语法,并使用创建一个流fromEvent()。当前滚动不会触发fromEvent订阅。

问题: 如何触发var source = Observable.fromEvent(target, 'window:scroll');

import { Directive, HostListener } from '@angular/core';
import {Observable} from "rxjs";
import 'rxjs/add/observable/fromEvent';

@Directive({
  selector: '[mh-scroll]'
})
export class MhScroll {
  lastKnownScrollPosition: number;
  ticking: boolean;

  constructor() {
    this.lastKnownScrollPosition = 0;
    this.ticking = false;
  }


    isElementCloseToTop(target) {

      var source = Observable.fromEvent(target, 'window:scroll'); //this never triggers.

      var subscription = source.subscribe(
          (x) => {
            console.log('Next: Clicked!');
          },
          (err) => {
            console.log('Error: %s', err);
          },
          () => {
            console.log('Completed'); …
Run Code Online (Sandbox Code Playgroud)

javascript dom-events observable rxjs angular

2
推荐指数
2
解决办法
3039
查看次数

角CDK的OverlayModule,cdk-overlay-pane不会将位置设置为绝对值吗?

我正在使用Angular CDK的Overlay模块。我只是找不到添加位置的方法:叠加层的绝对位置?该模块将接收top和的left位置,该位置与所连接元素的位置匹配,但是覆盖层将不接收position: absolute。由于ViewEncapsulation,我无法添加绝对位置。我真的很努力寻找解决方案。

问题: 如何使用cdkOverlayOrigincdkConnectedOverlayOrigin

模块:

import { OverlayModule } from '@angular/cdk/overlay';



@NgModule({
  imports: [
    OverlayModule,
  ],
  declarations: [ MenuComponent ],
})
export class MenuModule {
}
Run Code Online (Sandbox Code Playgroud)

零件:

@Component({
  selector: 'app-menu',
  templateUrl: './menu.component.html',
  styleUrls: [ './menu.component.scss' ],
})
export class MenuComponent {
}
Run Code Online (Sandbox Code Playgroud)

模板:

 <div style="margin: 0 auto; width: 30%">
  <h1 cdkOverlayOrigin
      #checkListTrigger="cdkOverlayOrigin"
      (click)="checkListOpen = !checkListOpen"
      style="background: blue">Overlay Origin</h1>
  <ng-template
    cdkConnectedOverlay
    [cdkConnectedOverlayOrigin]="checkListTrigger"
    [cdkConnectedOverlayOpen]="checkListOpen">

    <ng-container>
      <p>Why you no positioned on h1 element</p> …
Run Code Online (Sandbox Code Playgroud)

overlay angular-material2 angular angular-cdk

2
推荐指数
2
解决办法
1万
查看次数

如何向Observable.interval()添加延迟?

现在我正在使用setTimeout()我并不真正关心的东西.有本地运营商吗?我试过delay但不行?

import { Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
export class CarouselListComponent implements OnInit {
  public active = 0;
  @Input() public delay = 0;
  @Input() public interval = 5500;

  public ngOnInit(): void {
    setTimeout(()=> {
      Observable.interval(this.interval).subscribe(()=> {
        ++this.active;
      });
    }, this.delay);
  }
}
Run Code Online (Sandbox Code Playgroud)

delay intervals observable rxjs

2
推荐指数
1
解决办法
1910
查看次数