欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue-cli隨機(jī)生成port源碼的方法

 更新時(shí)間:2019年09月02日 11:27:59   作者:小碼農(nóng)雯  
這篇文章主要介紹了vue-cli隨機(jī)生成port源碼的方法,文中給大家介紹了vue 隨機(jī)色生成方法,需要的朋友可以參考下

vue-cli隨機(jī)生成port源碼的方法

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

兩行代碼

端口搜索范圍

默認(rèn)情況下,portfinder將開始搜索8000并掃描,直到達(dá)到最大端口號(hào)(65535)

源碼的路徑是在node_modules/@vue/cli-service/lib/commands/serve.js

知識(shí)點(diǎn)擴(kuò)展:

vue 隨機(jī)色生成

把標(biāo)題的顏色設(shè)置成隨機(jī)色

<h4 v-rainbow>標(biāo)題隨機(jī)色</h4>

在script寫局部自定義指令(如果想要寫全局的需要在main.js里面書寫)

局部

 directives:{
  'rainbow':{
    bind(el,binding,vnode){
    el.style.color = '#' + Math.random().toString(16).slice(2,8);//隨機(jī)顏色
   }
  },
 }

全局(main.js)

Vue.directive("rainbow",{
  bind(el,bind,vnode){
   el.style.color = '#' + Math.random().toString(16).slice(2,8);//隨機(jī)顏色
  }
})

總結(jié)

以上所述是小編給大家介紹的vue-cli隨機(jī)生成port源碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

相關(guān)文章

最新評(píng)論