index.tsx 912 B

1234567891011121314151617181920212223242526272829303132
  1. import { defineComponent, reactive, ref } from "vue";
  2. import styles from "./index.module.less";
  3. import { Icon } from "vant";
  4. export default defineComponent({
  5. name: "the-video",
  6. props:{
  7. src: {
  8. type: String,
  9. default: ''
  10. }
  11. },
  12. setup(props) {
  13. const videoRef = ref()
  14. const videoData = reactive({
  15. play: false,
  16. });
  17. const toggle = () => {
  18. videoData.play = !videoData.play
  19. if (videoData.play) {
  20. videoRef.value?.play()
  21. } else {
  22. videoRef.value?.pause()
  23. }
  24. }
  25. return () => (
  26. <div class={styles.wrap}>
  27. <video ref={videoRef} preload="auto" controls class={styles.video} src={props.src}></video>
  28. {/* <div class={styles.playBtn} onClick={toggle}>{videoData.play ? <Icon name="pause-circle" /> : <Icon name="play-circle" />}</div> */}
  29. </div>
  30. );
  31. },
  32. });