
vue3
chencaw
这个作者很懒,什么都没留下…
展开
-
vue3使用keeplive实现多页面缓存(1)
vue3使用keeplive实现多页面缓存原创 2022-09-23 08:39:20 · 1457 阅读 · 0 评论 -
vue3中watch的用户
1、单个变量watch,新旧变量依次的顺序import { reactive, ref, watch} from "vue";..................export default { name: 'xxxxx', setup() { watch( () => arrangeorder.data.devid, (newvalue,oldvalue) => { console.log("watchsssssss");原创 2021-11-25 11:46:35 · 371 阅读 · 0 评论 -
js中的indexof和includes
indexof为空(null或者undified)的时候判断应该有问题(1)return myBtns.includes(permission) (2)if(permission){ return myBtns.indexOf(permission) > -1}else{ return false }原创 2021-11-18 08:23:47 · 355 阅读 · 0 评论 -
vue3后端生产路由路径的懒加载方法
直接定义变量不能使用注意“飘”字符和变量{}的组合用法 //注意路径懒加载的方法 component:() => import(`@/views${child.component}.vue`),原创 2021-11-17 16:01:41 · 301 阅读 · 0 评论 -
vue3 中的router.addRoute和router.options.routes
问题:router.addRoute后用router.options.routes去都不更新参考Vue的router.addRoutes()不起作用解决方案 - 认真,是一种态度 - 博客园我的暂时解决import Layout from '@/layout/index.vue'import { useRouter} from "vue-router";export default { components: { SidebarItem, }, setup() {原创 2021-11-17 11:32:29 · 7732 阅读 · 0 评论 -
vue3打包后css和js的路径不对问题
参照官网后发现正确方法部署 | Vue CLI比如,我要把打包好的项目放在XXXXX.cn/chen/vue3下面(1)需要在vue.config.js的文件中做如下设置 module.exports = { //用于打包后修改路径,陈,最后上传时使用的设置,20211116 //参照了官网用法https://cli.vuejs.org/zh/guide/deployment.html#github-pages publicPath: process.env.NODE_ENV.原创 2021-11-16 14:33:14 · 5026 阅读 · 0 评论 -
Vue3 watch 侦听 props 的变化
转载于Vue3 watch 侦听 props 的变化 - 尹宇星_Kim - 博客园watch有两种写法// 侦听一个 getterconst state = reactive({ count: 0 })watch( () => state.count, (count, prevCount) => { /* ... */ })// 直接侦听一个 refconst count = ref(0)watch(count, (count, prevCo..转载 2021-11-10 13:56:05 · 15707 阅读 · 0 评论 -
vue3使用8--等待异步操作时渲染(suspense,模拟和axios采集)
可以在chrome中选择网络模拟速度1、测试1、模拟延迟测试(1)主程序<template> <h2>App父级组件:Suspense组件的使用</h2> <Suspense> <template #default> <!-- 异步组件 --> <async-component /> </template> <...原创 2021-08-26 10:59:41 · 1567 阅读 · 0 评论 -
vue3使用7--父子组件跨层传递消息(inject和provide)
1、provide 父传孙,跨阶层传 //父传孙,跨阶层传 provide('color',color)2、inject,接收const color = inject('color')3、代码结构(1)父代码<template> <h2>provide 与 inject</h2> <p>当前的颜色:{{color}}</p> <button @click="c...原创 2021-08-26 08:43:55 · 318 阅读 · 0 评论 -
vue3使用7--ref获取html页面元素
//例子需求:当页面加载完毕后,页面中的文本框可以直接获取焦点(自动获取焦点)1、代码<template> <h2>ref的另一个作用:可以获取页面中的元素</h2> <input type="text" ref="inputRef" /></template><script lang="ts">import { defineComponent, onMounted, ref} from 'vue'expo..原创 2021-08-26 07:04:13 · 8656 阅读 · 0 评论 -
vue3使用6--toRef的使用(定时器)
//toRefs可以把一个响应式对象转换成普通对象,该普通对象的每个property都是一个ref1、正常使用ref和定时器<template> <h2>toRefs的使用</h2> <h3>name:{{state.name}}</h3> <h3>age:{{state.age}}</h3></template><script lang="ts">import { def原创 2021-08-26 06:54:40 · 1642 阅读 · 0 评论 -
vue3使用5--axios请求封装使用
(1)如果axios没有安装npm install axios原创 2021-08-25 17:03:47 · 946 阅读 · 2 评论 -
vue3使用4--生命周期函数HOOK的使用(组合式API)
1、父组件<template> <h2>APP父级组件</h2> <button @click="isShow=!isShow">切换显示</button> <hr/> <Child v-if="isShow"/></template><script lang="ts">import Child from './components/Child.vue'i原创 2021-08-25 15:59:20 · 488 阅读 · 0 评论 -
vue3使用3--计算属性和监视
<template> <h2>计算属性和监视</h2> <fieldset> <legend>姓名操作</legend> <!-- 姓氏:<input type="text" placeholder="请输入姓氏" :model="user.firstName"/><br/> --> 姓氏:<input type="text" placeholder=".原创 2021-08-25 14:39:54 · 395 阅读 · 0 评论 -
vue3使用2--子传父--传递消息(setup,emit)
1、父组件<template> <h2>APP父级组件</h2> <h3>msg:{{msg}}</h3> <!-- <button @click="msg += '==='">更新数据</button> --> <button @click="sendmsg">更新数据</button> <hr/> <child :msg="msg" @c原创 2021-08-25 13:41:22 · 2041 阅读 · 0 评论 -
vue3使用1--父传子--组件传递消息(setup,props)
1、父组件<template> <h2>APP父级组件</h2> <h3>msg:{{msg}}</h3> <!-- <button @click="msg += '==='">更新数据</button> --> <button @click="sendmsg">更新数据</button> <hr/> <child :msg="msg"/原创 2021-08-25 13:29:33 · 1098 阅读 · 0 评论