小编Fou*_*_lo的帖子

D3.js - JSON数据数组将相同的数组元素绑定到所有内容

我正在加载一个GeoJSON数据文件,其中包含一个对象数组,每个对象包含不同国家/地区轮廓的矢量信息.相同的数组元素绑定到每个DOM元素.我之前在JavaScript中遇到过这个范围问题但是我所做的每一个改变都没有导致任何加载.

我附上了一个jsfiddle.我使用一个示例数据文件,似乎需要几秒钟加载.

来自jsfiddle的代码如下:

$(document).ready(function() {
  d3.json(
    "https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson",
    function(error, data) {
      var myGeoJSON = data.features;

      for (i = 0; i < myGeoJSON.length; i++) {
        var path = d3.geo.path();
        var width = 960;
        var height = 600;
        var svg = d3.select("body").append("svg")
          .attr("width", width)
          .attr("height", height);

        svg.selectAll("path")
          .data(data.features)
          .enter().append("path")
          .attr("d",path)
          .attr("fill","#3e429a");
      }
    }
  );
});
Run Code Online (Sandbox Code Playgroud)

javascript d3.js

16
推荐指数
1
解决办法
762
查看次数

脚本没有被调用

我正在使用ExpressJS.我的脚本或CSS不会加载.

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>Customer Info</title>

    <link rel="stylesheet" href="/stylesheets/testing.css" type="text/css" media="screen" charset="utf-8"/>

    <script type="text/javascript" src="/javascripts/jquery-1.9.1.js"></script>
    <script src="/javascripts/jquery-ui-1.10.2.custom.js" type="text/javascript" charset="utf-8"></script>

    <script type="text/javascript" src="/javascripts/testing.js"></script>



  </head>
   <body>
        //body contents
   </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我知道问题不在于位置.当我在express中呈现此EJS视图时,没有任何脚本正在加载.我无法理解为什么它可以用于几乎相同的视图,但不是这个视图.有任何想法吗?

html css node.js express

6
推荐指数
1
解决办法
452
查看次数

PassportJs,无法找到本地策略

我是javascript和node的新手.我按照passportJS的指南,我收到错误"无法找到本地策略".我不知道为什么.我的代码,基本上取自网站.

var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
, mongoose = require('mongoose')
, passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;

app.use(passport.initialize());


//to configure the passport
app.use(new LocalStrategy({
usernameField: 'username',
passwordField: 'password'
},
function(username, password, done){
    console.log(username);
    console.log(password);
    People.findOne({username:username},
    function(err, user){
        if(err){return done(err); }
        if(!user){
            return done(null, false, {message:
            'Incorrect username'});
        }
        if(!user.validPassword(password)){
            return done(null, false, {message:
            'Incorrect Password'});
        }
        return done(null, user);
    });
}
));


//route to …
Run Code Online (Sandbox Code Playgroud)

javascript node.js

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

标签 统计

javascript ×2

node.js ×2

css ×1

d3.js ×1

express ×1

html ×1