@df_business/tools-nj
v1.0.7
Published
nodeJS工具包
Downloads
16
Readme
nodeJS工具包
简介
- 包含了很多vue常用的程序
- package地址
测试
npm run test
发布
publish.bat
使用
# 安装
npm i @df_business/tools-nj --save
# 更新
npm update @df_business/tools-nj
# 移除
npm r @df_business/tools-nj
ws
main.js
let df_tools = require('@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
let df_tools = require('@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>