[英]subscriber in vue.js UI single file component
I am attempting to implement a subscriber in vue.js using rabbitmq-pubsub
, 我正在尝试使用
rabbitmq-pubsub
在vue.js中实现订户,
however, By doing 但是,通过
var Subscriber = require('rabbitmq-pubsub').Subscriber;
in terminal I see 在终端我看到
warning in ./node_modules/_colors@1.0.3@colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression
in browser console Is ee 在浏览器控制台中是ee
"[WDS] Warnings while compiling."
"./node_modules/_colors@1.0.3@colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression
@ ./node_modules/_colors@1.0.3@colors/lib/colors.js
@ ./node_modules/_colors@1.0.3@colors/safe.js
@ ./node_modules/_winston@1.1.2@winston/lib/winston/config.js
@ ./node_modules/_winston@1.1.2@winston/lib/winston.js
@ ./node_modules/_logfilename@0.1.3@logfilename/src/logfilename.js
@ ./node_modules/rabbitmq-pubsub/build/subscriber.js
@ ./node_modules/rabbitmq-pubsub/build/index.js
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/SelectServices.vue
@ ./src/components/SelectServices.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://10.9.1.147:8081 webpack/hot/dev-server ./src/main.js"
but when I did this : 但是当我这样做时:
var subscriberOptions = {
exchange: 'service_deployment_exchange',
queueName: queue,
url: amqpl_url
};
var subscriber = new Subscriber(subscriberOptions);
function onIncomingMessage(message) {
debug('onIncomingMessage ', message.fields);
console.log(message);
subscriber.ack(message);
//subscriber.nack(message);
};
but when I call the below line in the mounted function in the script element of of my vue single file complonent 但是当我在vue单个文件组件的脚本元素的已挂载函数中调用以下行时
subscriber.start(onIncomingMessage)
I get 我懂了
TypeError: fs.readdirSync is not a function
beside just the warning still showing up in console. 除了警告仍然显示在控制台上。
You can't use api of node in browser's code. 您不能在浏览器的代码中使用node的api。 And I think rabbitmq-pubsub is a node only module.
而且我认为Rabbitmq-pubsub是仅节点模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.