随笔分类 - Vue 合集 / Vue3
摘要:写法一: import type { myOrderItem } from '@/API/pages_mine/myOrder/types'; const props = defineProps({ item: { type: Object as PropType<myOrderItem>, def
阅读全文
摘要:子组件 // 组件名称:discountModel // 格式化数据 const fetchData = async () => { const { code, result } = await remind(); if(code 200) { data.value = result emit('u
阅读全文
摘要:更新方法,onLaunch或者onShow(推荐写在onShow内)调用就可以 const updateManagerFn = () => { const updateManager = uni.getUpdateManager(); updateManager.onCheckForUpdate(f
阅读全文
摘要:自定义样式使用第二种方式 第一种:wx.enableAlertBeforeUnload 在开发者工具中预览效果 微信小程序官网:点我 onShow(() => { wx.enableAlertBeforeUnload({ message: "返回上页时弹出对话框", success: functio
阅读全文
摘要:Vue3 子组件修改父组件传过来的值 // 父组件 <demo v-model:num="num" v-model:arr="arr"></demo> // 子组件 const prop=defineProps({ num: { type: Number, default:0 } }) const
阅读全文
摘要:使用网站 七牛云token生成:点我 七牛云上传接口错误码:点我 七牛云存储区域上传地址:点我 七牛云在线生成token 一般是后端生成,使用接口获取(放在后端比较安全) // 获取七牛云token export async function getQiniuToken() { const url
阅读全文
摘要:vue3 纯SCSS 实现环形进度条 <template> <view class="flex align-center diygw-col-24 justify-center"> <view class="progress-circle" :class="`progress-${innerPerc
阅读全文
摘要:安装pinia pnpm install pinia pnpm install pinia-plugin-persistedstate 使用pinia 根目录下创建store文件夹,新家moudules文件夹和index.ts文件,如图: index.ts 文件 // store/index.ts
阅读全文
摘要:Teleport 在组件外包裹一层,可以把组件放置在dom想要渲染的位置上; to:想要放置dom位置的父亲元素上的ID、class、html标签;disabled 值为 true,to 属性生效,反之,不生效; 以下代码,HelloWorldVue 组件为 ID 为 app 的子元素 <div c
阅读全文
摘要:**Reflect.get()**方法与从 对象 (target[propertyKey]) 中读取属性类似,但它是通过一个函数执行来操作的。 export const reactive = <T extends object>(target: T) => { return new Proxy(ta
阅读全文
摘要:ref 把对象转化为响应式的; shallowRef是浅层响应式数据,即:只有对value整体修改,才能更新到视图层。而修改具体属性值时,不会更新视图。(shallowReactive和shallowRef一样的效果); shallowRef() 存在的意义:将最终的结果输出到视图,节省一些不必要的
阅读全文
摘要:vue2 Object.defineProperty() Object.defineProperty() 方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性,并返回此对象。 每次劫持数据,都会层层遍历,影响性能,数组劫持数据,能劫持到push、pop、shift、unshift、等数组
阅读全文
摘要:方式一: main.js 设置全局变量 import api from '@/api' app.config.globalProperties.$api = api 使用全局变量,使用 getCurrentInstance 方法。 // ctx.$api 就是全局设置的变量 const { prox
阅读全文
摘要:App.vue 直接拷贝 <template> <el-config-provider :locale="locale"> <router-view /> </el-config-provider> </template> <script > import { ElConfigProvider }
阅读全文