Tag: 聚合物

Node.js / Express POST请求正文parsing为不正确的JSON

我有一个聚合物core-ajax组件发送一些数据到Node.js服务器。 数据正在正确发送(我可以用Go Web服务器parsing它),但是Node将它parsing为string化的正文,它是JSON对象中空白string的关键字: { '{"count":-1,"uid":1}': '' } 这是从聚合物发送请求的代码: sendCount: function(change) { console.log("Sending…"); console.log(JSON.stringify({"count": change, "uid": this.uid})); // ^ This prints: {"count":-1,"uid":1} this.$.ajax.body = JSON.stringify({"count": change, "uid": this.uid}); this.$.ajax.go(); } 这是节点代码: app.post("/post", function(req, res) { console.log(res.headers); console.log(req.body); // Prints { '{"count":-1,"uid":1}': '' } res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(req.body)); }); 当我得到响应返回它已经返回了格式不正确的JSON。 我如何正确parsing节点中的JSON? 也: app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false }));

聚合物:无法从模板初始化项目

我正在尝试使用我的第一个聚合物应用程序进行学习,然后卡住 我从这里开始: https : //www.polymer-project.org/1.0/start/toolbox/set-up 我成功安装了聚合物CLI。 现在,当我尝试从模板初始化项目时,它显示以下日志在我的cmd中: C:\Users\chint\Desktop\polymer-app>polymer init app-drawer-template info: Running template app-drawer-template info: Downloading latest release of Polymer/app-drawer-template info: Unpacking template files info: Finished writing template files I'm all done. Running bower install for you to install the required dependencies. If this fails, try running the command yourself. bower ENOENT No bower.json present […]

需要什么使聚合物安装和工作没有节点或NPM?

聚合物看起来非常好,我想尝试,但是对于我们的项目,Node不是我们平台的一部分,也不是。 制作不需要节点或NPM的聚合物项目需要什么?

最小的工作聚合物的例子

我一直在试图获得一个极其微小的网页使用Polymer来简单地在浏览器中呈现 – 我在服务器端使用Node / ExpressJS / Jade设置。 我的代码和Polymer文档附带的例子非常接近,我想我错过了一些非常简单的东西。 我正在使用Chrome M35。 在服务器上,我已经安装了所有聚合物的东西(平台,核心和纸)使用鲍尔,我已经映射bower_components静态/static app.use('/static', express.static(path.join(process.cwd(), 'bower_components'))) 我已经validation了我的服务器可以正确地为http://localhost:3000/static/paper-button/paper-button.html – 这将返回所需文件的内容。 该页面提供的HTML是这样的: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/static/platform/platform.js"></script> <title>Authenticate</title> <link rel="import" src="/static/paper-button/paper-button.html"> <style> body { font-family: 'Helvetica Neue'; margin: 0; padding: 24px; user-select: none; transform: translateZ(0); } paper-button { margin: 1em; width: 10em; } paper-button.colored { color: […]

(发生器 – 聚合物)聚合物失效,找不到模块'find-index'

在干净的目录中inputyo polymer后,这是完整的错误。 module.js:338 throw err; ^ Error: Cannot find module 'find-index' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/index.js:4:17) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) 我刚刚重新安装了所有相关的节点,但这里是版本。 node: v0.12.7 npm: 2.11.3 yo: 1.4.7 bower: 1.4.1 grunt-cli: v0.1.13 gulp: 3.9.0 generator-polymer: […]