摘要: // FancyInput组件作为子组件 函数组件 const FancyInput = React.forwardRef(()=> (props, ref) { const inputRef = useRef(); // 命令式的给`ref.current`赋值个对象 useImperativeH 阅读全文
posted @ 2023-07-10 10:31 马铃薯头抽雪茄 阅读(24) 评论(0) 推荐(0)
摘要: 1.先获取当前要监听的那个组件的ref import React, { useRef } from 'react'; // 类组件获取 this.Ref = React.createRef(); // 函数组件获取 const Ref = useRef(); 2.通过addEventListener 阅读全文
posted @ 2023-06-28 14:12 马铃薯头抽雪茄 阅读(143) 评论(0) 推荐(0)
摘要: 1.准备工作 let timer = null; // 定时器 const BoxRef = useRef(); // 父组件ref const ChildRef = useRef(); // 子组件ref用于包裹数据循环的 const [roll, setRoll] = useState(true 阅读全文
posted @ 2023-06-25 17:43 马铃薯头抽雪茄 阅读(412) 评论(0) 推荐(0)
摘要: 前言 fbemitter相当于是一个作用在全局的监听器 可用于想触发某个组件的函数可以通过开启监听来触发 正式开始~ 1.准备工作 npm install fbemitter 2.我一般实例化提出来单独作为引用文件 // 我这里把文件的名字定义为 singleton.js import { Even 阅读全文
posted @ 2023-06-19 16:06 马铃薯头抽雪茄 阅读(115) 评论(0) 推荐(0)
摘要: /** ** data.isPlay为显示那个按钮 ** startHandle开始定时器 setInterval ** pauseHandle,stopHandle理解为关闭定时器就好了clearInterval **/ <view class="btn" @click.stop="startHa 阅读全文
posted @ 2023-06-15 16:55 马铃薯头抽雪茄 阅读(576) 评论(0) 推荐(0)
摘要: return () => { }; // 改为这样return 解决意外语法问题 阅读全文
posted @ 2023-04-20 14:50 马铃薯头抽雪茄 阅读(81) 评论(0) 推荐(0)
摘要: 引入 uniapp 页面声明周期 <script setup> // 重点 import { ref } from 'vue' let index = ref("11"); onShow(() => { index.value = "22"; }); </script> 阅读全文
posted @ 2023-04-13 15:57 马铃薯头抽雪茄 阅读(162) 评论(0) 推荐(0)
摘要: 利用 componentWillReceiveProps 再子组件加入componentWillReceiveProps 当props跟新时就会触发此函数 那就可以再这里判断 当需要变更的数据变化时复制进去就可以了 componentWillReceiveProps(nextProps) {// 第 阅读全文
posted @ 2023-04-11 15:07 马铃薯头抽雪茄 阅读(579) 评论(0) 推荐(0)
摘要: 1.准备 import React, { useRef, useEffect } from 'react'; const useHorizontalScroll = ({ children, ...layoutProps }) => { const elRef = useRef(); useEffe 阅读全文
posted @ 2023-03-31 17:27 马铃薯头抽雪茄 阅读(457) 评论(0) 推荐(0)
摘要: 1.准备用到的数据 import React, { useContext, useState } from 'react'; import PropTypes from 'prop-types'; import { useLocation } from 'react-router-dom'; // 阅读全文
posted @ 2023-03-23 15:42 马铃薯头抽雪茄 阅读(1022) 评论(0) 推荐(0)