当前位置: 移动技术网 > IT编程>开发语言>JavaScript > vue-cli随机生成port源码的方法

vue-cli随机生成port源码的方法

2019年09月06日  | 移动技术网IT编程  | 我要评论

vue-cli随机生成port源码的方法

const portfinder = require('portfinder');
const port = await portfinder.getportpromise();

两行代码

端口搜索范围

默认情况下,portfinder将开始搜索8000并扫描,直到达到最大端口号(65535)

源码的路径是在

知识点扩展:

vue 随机色生成

把标题的颜色设置成随机色

<h4 v-rainbow>标题随机色</h4>

在script写局部自定义指令(如果想要写全局的需要在main.js里面书写)

局部

 directives:{
  'rainbow':{
    bind(el,binding,vnode){
    el.style.color = '#' + math.random().tostring(16).slice(2,8);//随机颜色
   }
  },
 }

全局(main.js)

vue.directive("rainbow",{
  bind(el,bind,vnode){
   el.style.color = '#' + math.random().tostring(16).slice(2,8);//随机颜色
  }
})

总结

以上所述是小编给大家介绍的vue-cli随机生成port源码,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网