@df_business/tools-nj

1.0.6 • Public • Published

nodeJS工具包

简介

测试

node test.js

发布

publish.bat

使用

# 安装
npm i @df_business/tools-nj --save
# 更新
npm update @df_business/tools-nj
# 移除
npm r @df_business/tools-nj

ws

main.js

import df_tools from '@df_business/tools-nj';
Vue.prototype.$ws = df_tools.ws;

index.vue

<script>
	export default {	
	data() {
		return {
			host:'127.0.0.1:90'		
		}
	},
	created() {
		this.ws=this.$ws(this,{token:'asdfasdf'});
	},		
	methods: {
		onopen: function() {
			console.log("服务器连接成功",this.ws.state());
		},
		onmessage: function(e) {
			console.log(e);
		},
		onclose: function() {
			console.log();
		},
		onerror: function(e) {
			console.log();
		},
		send: function(data) {
			this.ws.send(data);				
		}
	}
	}
</script>

http

main.js

import df_tools from '@df_business/tools-nj';
Vue.prototype.$http = df_tools.http;

index.vue

<script>
	export default {
	methods: {	
		get: function(para) {
			this.$http.get('', para).then(function(data) {
				console.log(data);
			})		
		},
		post: function(para) {
			this.$http.post('', para).then(function(data) {
				console.log(data);
			})		
		}		
	}
	}
</script>

Readme

Keywords

Package Sidebar

Install

npm i @df_business/tools-nj

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

36.7 kB

Total Files

11

Last publish

Collaborators

  • df_business