electron-vue項目使用串口工具serialport

第一步:配置環境
1.安裝Python2.7 配置環境變量(官網下載)看網上說明必須是2.7版本,3不支持
2.安裝 npm install --global --production windows-build-tools
3.安裝node-gyp npm install -g node-gypnode

第二步:安裝
1.安裝serialport npm install --save serialport
2.安裝electron-rebuild npm install --save-dev electron-rebuild
3.從新編譯(直接輸入命令): .\node_modules\.bin\electron-rebuild.cmdnpm

第三步:引入使用
1.import serialport from 'serialport'
2.serialport.list().then(
  ports => {windows

    //ports 串口
    console.log(ports)
  }
)electron

相關文章
相關標籤/搜索