当前位置:   article > 正文

微信小程序 实现蓝牙打印条形码,文字等_微信小程序蓝牙打印

微信小程序蓝牙打印
测试设备:得力DL-720W条码标签打印机
效果图:

具体代码如下:

1、搜索连接蓝牙

connect.wxml

  1. <view class="main">
  2. <van-button block type="info" bindtap="startSearch" loading='{{isScanning}}'>开始搜索</van-button>
  3. <scroll-view class="device-list" scroll-y scroll-with-animation>
  4. <view class="connect-name">已发现{{list.length}}个外围设备</view>
  5. <view
  6. wx:for="{{list}}"
  7. wx:for-item="item"
  8. data-title="{{item.deviceId}}"
  9. data-name="{{item.name}}"
  10. data-advertisData="{{item.advertisServiceUUIDs}}"
  11. data-item="{{item}}"
  12. wx:key="{{item.deviceId}}"
  13. bindtap="bindViewTap"
  14. >
  15. <view class="device-item">
  16. <view class="name">{{item.name}}</view>
  17. <view class="device-id">UUID: {{item.deviceId}}</view>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. <view wx:if="{{lastDevice}}">
  22. <view class="connect-name">最近连接的设备{{lastDevice.name}}</view>
  23. <view class="btn-area">
  24. <van-button block type="info" data-deviceId="{{lastDevice.deviceId}}" data-item="{{lastDevice}}" bindtap="createBLEConnectionWithDeviceId">直接连接</van-button>
  25. </view>
  26. </view>
  27. </view>

connect.scss

  1. .main{
  2. padding: 20rpx;
  3. .device-list{
  4. height: 700rpx;
  5. margin: 10rpx;
  6. .device-item{
  7. padding: 20rpx 0;
  8. border-bottom: 2rpx solid #E6EBF1;
  9. }
  10. .name{
  11. font-size: 32rpx;
  12. }
  13. .device-id{
  14. font-size: 24rpx;
  15. color: #666;
  16. }
  17. }
  18. .connect-name{
  19. text-align: center;
  20. padding: 15rpx 0;
  21. }
  22. }

connect.js

  1. let app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. list: [],
  8. services: [],
  9. serviceId: 0,
  10. writeCharacter: false,
  11. readCharacter: false,
  12. notifyCharacter: false,
  13. isScanning:false
  14. },
  15. // 开始搜索
  16. startSearch: function () {
  17. let that = this;
  18. if (!wx.openBluetoothAdapter) {
  19. wx.showModal({
  20. title: '提示',
  21. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  22. })
  23. return
  24. }
  25. // 初始化蓝牙设备
  26. wx.openBluetoothAdapter({
  27. success: function (res) {
  28. console.log('第一步,蓝牙初始化成功', res)
  29. // 获取本机蓝牙适配器状态
  30. wx.getBluetoothAdapterState({
  31. success: function (res) {
  32. // 蓝牙适配器是否可用
  33. if (res.available) {
  34. // 是否正在搜索设备
  35. if (res.discovering) {
  36. // 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
  37. wx.stopBluetoothDevicesDiscovery({
  38. success: function (res) {
  39. console.log(res)
  40. }
  41. })
  42. }
  43. that.checkPemission()
  44. } else {
  45. wx.showModal({
  46. title: '提示',
  47. content: '本机蓝牙不可用',
  48. })
  49. }
  50. },
  51. })
  52. }, fail: function () {
  53. wx.showModal({
  54. title: '提示',
  55. content: '蓝牙初始化失败,请打开蓝牙后重试',
  56. })
  57. }
  58. })
  59. },
  60. checkPemission: function () { //android 6.0以上需授权地理位置权限
  61. let that = this;
  62. let platform = app.BLEInformation.platform;
  63. if (platform == 'ios') {
  64. app.globalData.platform = 'ios';
  65. that.getBluetoothDevices()
  66. } else if (platform == 'android') {
  67. app.globalData.platform = 'android'
  68. console.log(app.getSystem().substring(app.getSystem().length - (app.getSystem().length - 8), app.getSystem().length - (app.getSystem().length - 8) + 1))
  69. if (app.getSystem().substring(app.getSystem().length - (app.getSystem().length - 8), app.getSystem().length - (app.getSystem().length - 8) + 1) > 5) {
  70. wx.getSetting({
  71. success: function (res) {
  72. console.log(res)
  73. if (!res.authSetting['scope.userLocation']) {
  74. wx.authorize({
  75. scope: 'scope.userLocation',
  76. complete: function (res) {
  77. that.getBluetoothDevices()
  78. }
  79. })
  80. } else {
  81. that.getBluetoothDevices()
  82. }
  83. }
  84. })
  85. }else{
  86. that.getBluetoothDevices()
  87. }
  88. }
  89. },
  90. getBluetoothDevices: function () { //获取蓝牙设备信息
  91. let that = this;
  92. wx.showLoading({ title: '正在加载'})
  93. that.setData({
  94. isScanning:true
  95. })
  96. // 开始搜寻附近的蓝牙外围设备。
  97. wx.startBluetoothDevicesDiscovery({
  98. success: function (res) {
  99. console.log(res)
  100. setTimeout(function () {
  101. wx.getBluetoothDevices({
  102. success: function (res) {
  103. let devices = []
  104. let num = 0
  105. for (let i = 0; i < res.devices.length; ++i) {
  106. if (res.devices[i].name != '未知设备') {
  107. devices[num] = res.devices[i]
  108. num++
  109. }
  110. }
  111. that.setData({
  112. list: devices,
  113. isScanning:false
  114. })
  115. wx.hideLoading()
  116. wx.stopPullDownRefresh()
  117. },
  118. })
  119. }, 3000)
  120. },
  121. })
  122. },
  123. // 连接蓝牙设备
  124. bindViewTap: function (e) {
  125. // 先清除之前已连接蓝牙设备数据缓存
  126. wx.removeStorageSync('bleItem');
  127. wx.removeStorageSync('bleWriteInfo');
  128. wx.removeStorageSync('bleNotifyInfo');
  129. let that = this;
  130. // 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索
  131. wx.stopBluetoothDevicesDiscovery({
  132. success: function (res) { console.log(res) },
  133. })
  134. that.setData({
  135. serviceId: 0,
  136. writeCharacter: false,
  137. readCharacter: false,
  138. notifyCharacter: false
  139. })
  140. wx.showLoading({ title: '正在连接' })
  141. const { title,item } = e.currentTarget.dataset;
  142. this._createBLEConnection(title,item)
  143. },
  144. // 连接蓝牙低功耗设备。
  145. // 若小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备,无需再次进行搜索操作。
  146. _createBLEConnection(deviceId,item){
  147. const that = this;
  148. wx.createBLEConnection({
  149. deviceId: deviceId,
  150. success: function (res) {
  151. console.log(res)
  152. app.BLEInformation.deviceId = deviceId;
  153. // 把已连接的蓝牙设备存入缓存
  154. wx.setStorageSync('bleItem', item);
  155. that.getSeviceId()
  156. }, fail: function (e) {
  157. console.log(e,'连接失败')
  158. // wx.showModal({
  159. // title: '提示',
  160. // content: '连接失败',
  161. // })
  162. console.log(e)
  163. }, complete: function (e) {
  164. console.log(e)
  165. wx.hideLoading()
  166. }
  167. })
  168. },
  169. // 获取蓝牙低功耗设备所有服务 (service)。
  170. getSeviceId: function () {
  171. let that = this
  172. let platform = app.BLEInformation.platform;
  173. wx.getBLEDeviceServices({
  174. deviceId: app.BLEInformation.deviceId,
  175. success: function (res) {
  176. console.log(res)
  177. that.setData({ services: res.services })
  178. that.getCharacteristics()
  179. }, fail: function (e) {
  180. console.log(e)
  181. }, complete: function (e) {
  182. console.log(e)
  183. }
  184. })
  185. },
  186. getCharacteristics: function () {
  187. let that = this;
  188. let list = that.data.services;
  189. let num = that.data.serviceId;
  190. let write = that.data.writeCharacter;
  191. let read = that.data.readCharacter;
  192. let notify = that.data.notifyCharacter;
  193. // 获取蓝牙低功耗设备某个服务中所有特征 (characteristic)。
  194. wx.getBLEDeviceCharacteristics({
  195. deviceId: app.BLEInformation.deviceId,
  196. serviceId: list[num].uuid,
  197. success: function (res) {
  198. console.log(res)
  199. for (let i = 0; i < res.characteristics.length; ++i) {
  200. let properties = res.characteristics[i].properties;
  201. let item = res.characteristics[i].uuid;
  202. if (!notify) {
  203. if (properties.notify) {
  204. app.BLEInformation.notifyCharaterId = item
  205. app.BLEInformation.notifyServiceId = list[num].uuid;
  206. const bleNotifyInfo = {
  207. notifyCharaterId: item,
  208. notifyServiceId: list[num].uuid
  209. }
  210. wx.setStorageSync('bleNotifyInfo', bleNotifyInfo);
  211. notify = true
  212. }
  213. }
  214. if (!write) {
  215. if (properties.write) {
  216. app.BLEInformation.writeCharaterId = item;
  217. app.BLEInformation.writeServiceId = list[num].uuid;
  218. const bleWriteInfo = {
  219. writeCharaterId: item,
  220. writeServiceId: list[num].uuid
  221. }
  222. wx.setStorageSync('bleWriteInfo', bleWriteInfo);
  223. write = true;
  224. }
  225. }
  226. if (!read) {
  227. if (properties.read) {
  228. app.BLEInformation.readCharaterId = item;
  229. app.BLEInformation.readServiceId = list[num].uuid;
  230. read = true
  231. }
  232. }
  233. }
  234. if (!write || !notify || !read) {
  235. num++
  236. that.setData({
  237. writeCharacter: write,
  238. readCharacter: read,
  239. notifyCharacter: notify,
  240. serviceId: num
  241. })
  242. if(num == list.length){
  243. wx.showModal({
  244. title: '提示',
  245. content: '找不到该读写的特征值',
  246. })
  247. }else{
  248. that.getCharacteristics()
  249. }
  250. } else {
  251. that.openControl()
  252. }
  253. }, fail: function (e) {
  254. console.log(e)
  255. }, complete: function (e) {
  256. console.log('write:'+app.BLEInformation.writeCharaterId)
  257. console.log('read:'+app.BLEInformation.readCharaterId)
  258. console.log('notify:'+app.BLEInformation.notifyCharaterId)
  259. }
  260. })
  261. },
  262. openControl: function () {
  263. wx.showToast({
  264. title: '连接成功',
  265. icon: 'success',
  266. duration: 2000
  267. })
  268. wx.navigateBack({
  269. delta: 1
  270. })
  271. },
  272. createBLEConnectionWithDeviceId(e) {
  273. // 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
  274. const device = this.data.lastDevice;
  275. if (!device) { return }
  276. const deviceId = device.deviceId;
  277. console.log('createBLEConnectionWithDeviceId', deviceId)
  278. wx.openBluetoothAdapter({
  279. success: (res) => {
  280. console.log('openBluetoothAdapter success', res)
  281. this._createBLEConnection(deviceId, device)
  282. },
  283. fail: (res) => {
  284. console.log('openBluetoothAdapter fail', res)
  285. if (res.errCode === 10001) {
  286. wx.showModal({
  287. title: '错误',
  288. content: '未找到蓝牙设备, 请打开蓝牙后重试。',
  289. showCancel: false
  290. })
  291. wx.onBluetoothAdapterStateChange((res) => {
  292. console.log('onBluetoothAdapterStateChange', res)
  293. if (res.available) {
  294. // 取消监听
  295. wx.onBluetoothAdapterStateChange(() => {
  296. });
  297. this._createBLEConnection(deviceId, device)
  298. }
  299. })
  300. }
  301. }
  302. })
  303. },
  304. /**
  305. * 生命周期函数--监听页面加载
  306. */
  307. onLoad: function (options) {
  308. app.BLEInformation.platform = app.getPlatform();
  309. wx.setStorageSync('platform', app.getPlatform());
  310. const lastDevice = wx.getStorageSync('bleItem');
  311. this.setData({
  312. lastDevice: lastDevice
  313. })
  314. },
  315. /**
  316. * 生命周期函数--监听页面初次渲染完成
  317. */
  318. onReady: function () {
  319. },
  320. /**
  321. * 生命周期函数--监听页面显示
  322. */
  323. onShow: function () {
  324. },
  325. /**
  326. * 生命周期函数--监听页面隐藏
  327. */
  328. onHide: function () {
  329. },
  330. /**
  331. * 生命周期函数--监听页面卸载
  332. */
  333. onUnload: function () {
  334. },
  335. /**
  336. * 页面相关事件处理函数--监听用户下拉动作
  337. */
  338. onPullDownRefresh: function () {
  339. let that = this
  340. wx.startPullDownRefresh({})
  341. that.startSearch()
  342. },
  343. /**
  344. * 页面上拉触底事件的处理函数
  345. */
  346. onReachBottom: function () {
  347. },
  348. /**
  349. * 用户点击右上角分享
  350. */
  351. onShareAppMessage: function () {
  352. }
  353. })

效果图

2、打印功能(单独写在了mixins里)

send-command.js

  1. /**
  2. * 此Demo仅供参考,可打印数字,英文,符号,中文,条形码
  3. * 小程序支持的蓝牙为低功耗蓝牙(BLE),数据量大需分包发送
  4. */
  5. const app = getApp();
  6. export default {
  7. data: {
  8. looptime: 0,
  9. currentTime: 1,
  10. lastData: 0,
  11. buffSize: [],
  12. buffIndex: 0,
  13. printNum: [],
  14. printNumIndex: 0,
  15. printerNum: 1,
  16. currentPrint: 1,
  17. isReceiptSend: false,
  18. isLabelSend: false,
  19. canvasWidth: 180,
  20. canvasHeight: 180,
  21. imageSrc: '../../../images/mine/user-free.png',
  22. isBleConnect: false // 是否已连接蓝牙设备
  23. },
  24. //准备发送,根据每次发送字节数来处理分包数量
  25. prepareSend: function(buff) {
  26. console.log(buff)
  27. let that = this;
  28. let time = that.data.oneTimeData;
  29. let looptime = parseInt(buff.length / time);
  30. let lastData = parseInt(buff.length % time);
  31. console.log(looptime + '---' + lastData)
  32. that.setData({
  33. looptime: looptime + 1,
  34. lastData: lastData,
  35. currentTime: 1,
  36. })
  37. that.Send(buff)
  38. },
  39. //分包发送
  40. Send: function(buff) {
  41. let that = this;
  42. let currentTime = that.data.currentTime;
  43. let loopTime = that.data.looptime;
  44. let lastData = that.data.lastData;
  45. let onTimeData = that.data.oneTimeData;
  46. let printNum = that.data.printerNum;
  47. let currentPrint = that.data.currentPrint;
  48. let buf;
  49. let dataView;
  50. if (currentTime < loopTime) {
  51. buf = new ArrayBuffer(onTimeData)
  52. dataView = new DataView(buf)
  53. for (let i = 0; i < onTimeData; ++i) {
  54. dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
  55. }
  56. } else {
  57. buf = new ArrayBuffer(lastData)
  58. dataView = new DataView(buf)
  59. for (let i = 0; i < lastData; ++i) {
  60. dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
  61. }
  62. }
  63. const bleWriteInfo = wx.getStorageSync('bleWriteInfo');
  64. console.log(bleWriteInfo,'bleWriteInfo=====')
  65. wx.writeBLECharacteristicValue({
  66. deviceId: this.data.bleInfo.deviceId,
  67. serviceId: bleWriteInfo.writeServiceId,
  68. characteristicId: bleWriteInfo.writeCharaterId,
  69. value: buf,
  70. success: function(res) {
  71. console.log(res)
  72. },
  73. fail: function(e) {
  74. console.log(e)
  75. },
  76. complete: function() {
  77. currentTime++
  78. if (currentTime <= loopTime) {
  79. that.setData({
  80. currentTime: currentTime
  81. })
  82. that.Send(buff)
  83. } else {
  84. wx.showToast({
  85. title: '已打印第' + currentPrint + '张',
  86. })
  87. if (currentPrint == printNum) {
  88. that.setData({
  89. looptime: 0,
  90. lastData: 0,
  91. currentTime: 1,
  92. isReceiptSend: false,
  93. isLabelSend: false,
  94. currentPrint: 1
  95. })
  96. } else {
  97. currentPrint++
  98. that.setData({
  99. currentPrint: currentPrint,
  100. currentTime: 1,
  101. })
  102. that.Send(buff)
  103. }
  104. }
  105. }
  106. })
  107. },
  108. // 启用蓝牙低功耗设备特征值变化时的 notify 功能,订阅特征
  109. enableBle(deviceId){
  110. const bleNotifyInfo = wx.getStorageSync('bleNotifyInfo');
  111. wx.notifyBLECharacteristicValueChange({
  112. deviceId: deviceId,
  113. serviceId: bleNotifyInfo.notifyServiceId,
  114. characteristicId: bleNotifyInfo.notifyCharaterId,
  115. state: true,
  116. success: function(res) {
  117. wx.onBLECharacteristicValueChange(function(r) {
  118. console.log(`characteristic ${r.characteristicId} has changed, now is ${r}`)
  119. })
  120. },
  121. fail: function(e) {
  122. console.log(e)
  123. },
  124. complete: function(e) {
  125. console.log(e)
  126. }
  127. })
  128. },
  129. drawCanvas(){
  130. let that = this;
  131. let width;
  132. let height;
  133. wx.getImageInfo({
  134. src: that.data.imageSrc,
  135. success(res) {
  136. width = res.width
  137. height = res.height
  138. that.setData({
  139. canvasWidth: res.width,
  140. canvasHeight: res.height
  141. })
  142. }
  143. })
  144. const ctx = wx.createCanvasContext('edit_area_canvas', this);
  145. ctx.drawImage(this.data.imageSrc, 0, 0, width, height);
  146. ctx.draw();
  147. },
  148. // 创建连接
  149. _createBLEConnection(deviceId,item){
  150. const that = this;
  151. wx.createBLEConnection({
  152. deviceId: deviceId,
  153. success: function (res) {
  154. console.log(res)
  155. wx.setStorageSync('bleItem', item);
  156. // that.getSeviceId(deviceId)
  157. }, fail: function (e) {
  158. console.log('createBLEConnection fail', res)
  159. }, complete: function (e) {
  160. wx.hideLoading()
  161. }
  162. })
  163. },
  164. // 创建蓝牙连接
  165. // 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
  166. createBLEConnectionWithDeviceId() {
  167. const device = this.data.bleInfo;
  168. if (!device) { return; }
  169. const deviceId = device.deviceId;
  170. console.log('createBLEConnectionWithDeviceId', deviceId)
  171. wx.openBluetoothAdapter({
  172. success: (res) => {
  173. console.log('openBluetoothAdapter success', res)
  174. this._createBLEConnection(deviceId, device)
  175. },
  176. fail: (res) => {
  177. console.log('openBluetoothAdapter fail', res)
  178. if (res.errCode === 10001) {
  179. wx.showModal({
  180. title: '错误',
  181. content: '未找到蓝牙设备, 请打开蓝牙后重试。',
  182. showCancel: false
  183. })
  184. wx.onBluetoothAdapterStateChange((res) => {
  185. console.log('onBluetoothAdapterStateChange', res)
  186. // 蓝牙适配器是否可用
  187. if (res.available) {
  188. // 取消监听,否则stopBluetoothDevicesDiscovery后仍会继续触发onBluetoothAdapterStateChange,
  189. // 导致再次调用startBluetoothDevicesDiscovery
  190. wx.onBluetoothAdapterStateChange(() => {});
  191. this._createBLEConnection(deviceId, device)
  192. }
  193. })
  194. }
  195. }
  196. })
  197. },
  198. /**
  199. * 生命周期函数--监听页面加载
  200. */
  201. onLoad: function () {
  202. this.enableBle()
  203. },
  204. /**
  205. * 生命周期函数--监听页面初次渲染完成
  206. */
  207. onReady: function() {
  208. let list = [];
  209. let numList = [];
  210. let j = 0;
  211. for (let i = 20; i < 200; i += 10) {
  212. list[j] = i;
  213. j++
  214. }
  215. for (let i = 1; i < 10; i++) {
  216. numList[i - 1] = i
  217. }
  218. this.setData({
  219. buffSize: list,
  220. oneTimeData: list[0],
  221. printNum: numList,
  222. printerNum: numList[0]
  223. })
  224. },
  225. onShow() {
  226. this.drawCanvas();
  227. // 获取已经连接过得蓝牙设备
  228. const bleInfo = wx.getStorageSync('bleItem');
  229. this.setData({
  230. bleInfo: bleInfo ? bleInfo : {}
  231. })
  232. // 如果已经有连接的蓝牙设备,直接连接
  233. if(Object.keys(this.data.bleInfo).length !== 0){
  234. this.setData({
  235. isBleConnect: true
  236. })
  237. this.createBLEConnectionWithDeviceId()
  238. // this.enableBle(this.data.bleInfo.deviceId);
  239. }
  240. },
  241. /**
  242. * 生命周期函数--监听页面卸载
  243. */
  244. onUnload: function() {
  245. // 断开与蓝牙低功耗设备的连接
  246. wx.closeBLEConnection({
  247. deviceId: this.data.bleInfo.deviceId,
  248. success: function(res) {
  249. console.log("关闭蓝牙成功")
  250. },
  251. })
  252. }
  253. }

3、业务中打印逻辑

wxml

<van-button wx:if="{{detailBase.state <= 3}}" color="#0A7DFE" loading="{{btnLoading}}" block round bind:tap="labelPrint">打印</van-button>

js

  1. import sendCommand from '@/mixins/modules/send-command.js';
  2. let tsc = require('../../../utils/tsc.js');
  3. Page({
  4. mixins: [sendCommand],
  5. // 标签打印
  6. labelPrint(){
  7. // 如果未连接打印机,跳转到连接打印机页面
  8. if(Object.keys(this.data.bleInfo).length === 0){
  9. wx.navigateTo({
  10. url: '/pages/tabbar-pages/mine/bleConnect/bleConnect'
  11. })
  12. return;
  13. }
  14. let that = this;
  15. let canvasWidth = that.data.canvasWidth;
  16. let canvasHeight = that.data.canvasHeight;
  17. let command = tsc.jpPrinter.createNew();
  18. command.setSize(65, 48);
  19. command.setGap(0);
  20. command.setCls();
  21. command.setText(220, 10, 'TSS24.BF2', 1, 1, '暂存单');
  22. command.setBarCode(95, 50, '128', 65, 1, 2, 2, `${that.data.detailBase.id}`);
  23. command.setText(190, 120, 'TSS24.BF2', 1, 1, `${that.data.detailBase.id}`);
  24. command.setText(30, 160, 'TSS24.BF2', 1, 1, `姓名:${that.data.detailBase.name}`);
  25. command.setText(240, 160, 'TSS24.BF2', 1, 1, `手机号:${that.data.detailBase.mobile}`);
  26. that.data.goodsInfo.forEach((item,index)=>{
  27. if(index < 3){
  28. command.setText(30, 200 + index * 40, 'TSS24.BF2', 1, 1, `物品${index+1}:${item.goodsName}/${item.goodsAmount}/${item.goodsStatus}`);
  29. }
  30. })
  31. // 获取 canvas 区域隐含的像素数据。
  32. wx.canvasGetImageData({
  33. canvasId: 'edit_area_canvas',
  34. x: 0,
  35. y: 0,
  36. width: canvasWidth,
  37. height: canvasHeight,
  38. success: function(res) {
  39. command.setBitmap(60, 0, 1, res)
  40. },
  41. complete: function() {
  42. command.setPagePrint()
  43. that.setData({ isLabelSend: true })
  44. that.prepareSend(command.getData())
  45. }
  46. })
  47. setTimeout(()=>{
  48. that.onPrint()
  49. },500)
  50. }
  51. })

打印需要的插件

 encoding.js和encoding-indexes.js 下载地址text-encoding - npmPolyfill for the Encoding Living Standard's API.. Latest version: 0.7.0, last published: 6 years ago. Start using text-encoding in your project by running `npm i text-encoding`. There are 764 other projects in the npm registry using text-encoding.icon-default.png?t=N7T8https://www.npmjs.com/package/text-encoding?activeTab=code

tsc.js 见下篇

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/905435
推荐阅读
相关标签
  

闽ICP备14008679号