之后缺少名字。运算符YUI Compressor for socket.io js文件 [英] Missing name after . operator YUI Compressor for socket.io js files

查看:125
本文介绍了之后缺少名字。运算符YUI Compressor for socket.io js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用基于socket.io的.js文件的YUI压缩器(是的,我知道它是服务器端脚本并且不需要minfication,但它是必需的,因此我的控制较少)。我的代码是这样的:

I am trying to use YUI compressor for socket.io based .js file (yes, I know it's server side script and doesn't require minfication, but it's requirement so I have a less control). My code is like this:

fs.readFile('../examples/example.xml', function(err, data) {
  if (err) throw err;
  // parsing the new xml data and converting them into json file
  var json = parser.toJson(data);
  // adding the time of the last update
  json.time = new Date();
  // send the new data to the client
  socket.volatile.emit('notification', json);
});

当我执行YUI压缩器时,我得到错误@这一行:

When I execute YUI compressor I get error @ this line:

socket.volatile.emit('notification', json);

[ERROR] 36:22:missing name after . operator

我认为它抛出错误因为volatile是关键字对吗?任何人都可以指导我如何摆脱这个错误。

I assume it is throwing error becase volatile is keyword right? Can anyone guide me how to get rid of this error.

推荐答案

如果用引号括起来,没有压缩器会弄乱保留字



no compressor will mess with reserved words if enclosed in quotes

socket['volatile'].emit() 

这篇关于之后缺少名字。运算符YUI Compressor for socket.io js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆