Преглед на файлове

🐛 fix(v-qrcode): 修复初始值为空的情况

晓晓晓晓丶vv преди 4 години
родител
ревизия
b093286beb
променени са 1 файла, в които са добавени 2 реда и са изтрити 0 реда
  1. 2 0
      src/plugins/vue-qrcode.ts

+ 2 - 0
src/plugins/vue-qrcode.ts

@@ -20,6 +20,7 @@ const bind = async (
 ) => {
   console.log("mounted:", binding);
   const qrText = binding.value;
+  if (!qrText) return;
   if (typeof qrText === "string") {
     const code = await QRCode.toDataURL(qrText);
     insertQrCode2Element(el, code);
@@ -30,6 +31,7 @@ const update = async (el: HTMLElement | Element, binding: DirectiveBinding) => {
   if (binding.oldValue === binding.value) return;
   console.log("update:", binding);
   const qrText = binding.value;
+  if (!qrText) return;
   if (typeof qrText === "string") {
     const code = await QRCode.toDataURL(qrText);
     insertQrCode2Element(el, code);