liushengqiang 2 lat temu
rodzic
commit
53896a8f5a
1 zmienionych plików z 12 dodań i 1 usunięć
  1. 12 1
      src/components/TheNoticeBar/index.tsx

+ 12 - 1
src/components/TheNoticeBar/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, onMounted, reactive, ref } from 'vue';
+import { defineComponent, onMounted, reactive, ref, watch } from 'vue';
 import styles from './index.module.less';
 
 export default defineComponent({
@@ -7,6 +7,10 @@ export default defineComponent({
     text: {
       type: String,
       default: ''
+    },
+    isAnimation: {
+      type: Boolean,  
+      default: false
     }
   },
   setup(props) {
@@ -56,6 +60,13 @@ export default defineComponent({
       notiData.contentStyle.transform = 'translateX(0px)';
       notiData.time = null;
     };
+    watch(() => props.isAnimation, (val) => {
+      if (val) {
+        init();
+      } else {
+        stopAnimate();
+      }
+    })
     return () => (
       <div
         ref={wrapRef}