上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 98 下一页
摘要: 1、优点 代码功能模块化,复用代码 2、建立 新建hooks文件夹,在src下 src/hooks/use功能.js 3、案例 a、模块化 src/hooks/usepoint.js import { reactive, onMounted, onBeforeUnmount} from 'vue'; 阅读全文
posted @ 2025-01-10 11:05 市丸银 阅读(35) 评论(0) 推荐(0)
摘要: vue.config.js const { defineConfig } = require('@vue/cli-service') const {DefinePlugin} = require('webpack') module.exports = defineConfig({ transpile 阅读全文
posted @ 2025-01-10 10:14 市丸银 阅读(301) 评论(0) 推荐(0)
摘要: 一、引入 ,写在setup里面 import {onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted} from 'vue'; 二、与Vue2的关系 setup() > beforecrea 阅读全文
posted @ 2025-01-10 10:06 市丸银 阅读(61) 评论(0) 推荐(0)
摘要: 1、watch:既要指明监视的属性,也要指明监视的回调 2、watchEffect:不要指明监视的属性,监视的回调用哪个属性,就监视哪个属性 3、语法 a、引入 import { watchEffect } from 'vue'; b、使用 // 不用指明监视属性,监视回调中使用的属性 watchE 阅读全文
posted @ 2025-01-10 08:41 市丸银 阅读(41) 评论(0) 推荐(0)
摘要: 一、引入 import {reactive, watch } from 'vue' 二、注意 1、监视reactive定义的响应式对象时,oldval无法正确获取,强制开启深度监视,无法关闭 2、监视reactive对象的某个属性时,deep有效(属性为对象),属性为字符串或数字 oldvalue可 阅读全文
posted @ 2025-01-09 23:25 市丸银 阅读(232) 评论(0) 推荐(0)
摘要: 1、引用 import {ref, watch } from 'vue' 2、监视两种方法,属性ref,immediate deep可以直接写,比vue2简单 a、监听一个 // 第一种写法,监视 一个 immediate deep watch(num, (newVal, oldVal) => { 阅读全文
posted @ 2025-01-09 22:16 市丸银 阅读(91) 评论(0) 推荐(0)
摘要: 一、与vue2的computed配置功能一致 二、用法 1、引入 import {computed } from 'vue'; 2、计算属性简写(get) setup(props, context){ let fullNmae = computed(() => { return person.fir 阅读全文
posted @ 2025-01-09 19:59 市丸银 阅读(402) 评论(0) 推荐(0)
摘要: 一、执行时机 在beforecreate生命周期函数前执行一次,且this为undefined 二、setup参数 1、props:值为对象,组件外部传递过来,且组件内部通过props:[]接受的值 a、外部组件传递 <Demon msg="Hello" :num="10"/> b、且内部组件接受 阅读全文
posted @ 2025-01-09 16:34 市丸银 阅读(121) 评论(0) 推荐(0)
摘要: 1、通过Proxy(代理):拦截对象中任意属性变化,包括:属性的读写、添加、删除 2、通过Reflect(反射):对被代理的属性进行操作 <script type="text/javascript"> new Proxy(data, { // 读书属性 get(target, prop){ retu 阅读全文
posted @ 2025-01-09 15:05 市丸银 阅读(32) 评论(0) 推荐(0)
摘要: 1、作用 定义一个对象的响应式数据(基本类型不用它,用ref) 2、使用 a、引入 import { reactive } from 'vue'; b、语法 const 代理对象= recative(源对象) 源对象可以是数组或对象,返回Proxy对象的实例对象 3、reactive定义的响应式是深 阅读全文
posted @ 2025-01-09 14:02 市丸银 阅读(46) 评论(0) 推荐(0)
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 98 下一页