摘要: 一句话解释: 双向绑定顾名思义, 使用v-bind实现data=>input, 使用@input事件实现input=>data 1 v-model 用在 input 元素上时 使用 <input v-model="sth" /> 原理 <input v-model="sth" /> 等价于: <in 阅读全文
posted @ 2022-02-23 23:25 波吉国王 阅读(50) 评论(0) 推荐(0) 编辑
摘要: import { mapState , mapGetters} from 'vuex' computed: { ...mapGetters(['attrsList', 'goodsList', 'trademarkList']), ...mapState({total: (state) => sta 阅读全文
posted @ 2022-02-23 23:24 波吉国王 阅读(45) 评论(0) 推荐(0) 编辑
摘要: npm install mockjs --save -dev开发时使用 1 src下创建文件夹mock 文件夹mock下创建banner.json 和 mockServe.js [ { "id": "1", "imgUrl": "/images/banner1.jpg" }, { "id": "2" 阅读全文
posted @ 2022-02-23 23:24 波吉国王 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 区别 data中的属性并不会随赋值变量的改动而改动 computed属性属于持续变化跟踪。在computed属性定义的时候,这个computed属性就与给它赋值的变量绑定了。改变这个赋值变量,computed属性值会随之改变 错误使用场景 <div>{{name}}</div> data() { r 阅读全文
posted @ 2022-02-23 23:21 波吉国王 阅读(1345) 评论(0) 推荐(0) 编辑
摘要: 1 vue-cli3以后工程文件夹中是没有vue.config.js这个文件的,所以我们需要自己创建一个 2 npm run serve可以将项目在本地和通过ip方式都跑起来。我们不需要再去配置webpack, 下面的Network后为本机ip地址 App running at: - Local: 阅读全文
posted @ 2022-02-23 23:20 波吉国王 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 1 先放在 created 里 首先我们先将请求放在 created 里,如下: created(){ console.log('created'); this.$store.dispatch('getDetail', 11); }, mounted(){ console.log('mounted' 阅读全文
posted @ 2022-02-23 23:20 波吉国王 阅读(1906) 评论(0) 推荐(0) 编辑
摘要: 1 父=>子 父:msg='msg' 子props 单向数据流,子组件不允许改变props的值,如msg 2 子=>父 子事件里触发事件this.$emit(名 , 参) 父@名='fn' fn(参) 在组件上写event,都是自定义事件 即便: <Son @click='fn'/> 点击不会触发c 阅读全文
posted @ 2022-02-23 23:18 波吉国王 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 路由守卫的afterEach() 方法有个常用的地方是自动让页面返回最顶端 比如一个页面较长,滚动到某个位置后跳转。这时另一个页面滚动条默认是上一个页面停留的位置。我们可以在 afterEach() 方法中将滚动条位置进行重置。 //全局路由改变后钩子 router.afterEach((to, f 阅读全文
posted @ 2022-02-23 23:18 波吉国王 阅读(702) 评论(0) 推荐(0) 编辑
摘要: // 添加请求拦截器 requests.interceptors.request.use( function (config) { // 在发送请求之前做些什么 if(store.state.Detail.uuid_token){ config.headers.userTempId = store. 阅读全文
posted @ 2022-02-23 23:17 波吉国王 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 一句话解释: 在script里 99% 是要写this. 在Vue 中会定义很多的函数或者变量 data computed methods prop filter 路由相关等 这些属性或方法往往需要在 template 或者 script 标签中使用 在template 中直接使用不需要this 在 阅读全文
posted @ 2022-02-23 23:17 波吉国王 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 一句话解释 跳到哪个路由, 加载哪个组件 (增加首屏加载速度) 原来: import Home from '../pages/Home' const routes = [ { path: '/home', name: 'home', component: Home, } ] 现在: const ro 阅读全文
posted @ 2022-02-23 23:16 波吉国王 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 1 create vue demo时, 选择如下设置: (*) Choose Vue version //2 (*) Babel ( ) TypeScript ( ) Progressive Web App (PWA) Support (*) Router //not history (*) Vue 阅读全文
posted @ 2022-02-23 23:16 波吉国王 阅读(974) 评论(0) 推荐(0) 编辑
摘要: QR Code码 Quick Response Code快速响应码 下载 npm install --save qrcode 引入 import QRCode from 'qrcode'; 使用 let text='ztyj34thj34hgfds23' let url = await QRCode 阅读全文
posted @ 2022-02-23 23:15 波吉国王 阅读(130) 评论(0) 推荐(0) 编辑
摘要: <template> <div class="swiper-slide" v-for="(carousel, index) in bannerList" :key="carousel.id" > <img :src="carousel.imgUrl" alt="" /> </div> </templ 阅读全文
posted @ 2022-02-23 23:14 波吉国王 阅读(923) 评论(0) 推荐(0) 编辑
摘要: call apply bind box.onclick = function(){ function fn(){ alert(this); } fn(); //window.fn() this指向window }; 1 我们原本以为这里面的this指向的是box,然而却是Window。一般我们这样解 阅读全文
posted @ 2022-02-23 23:10 波吉国王 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 吃水不忘挖井人 svg基础教程https://www.bilibili.com/video/BV1Pt411y7V6?p=1 要实现的效果 svg文件的写法: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DT 阅读全文
posted @ 2022-02-23 23:09 波吉国王 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 容器属性 1父容器 属性 值 display: flex justify-content主轴: flex-start flex-end center space-around space-between align-items副轴:没有两端对齐 flex-start flex-end center 阅读全文
posted @ 2022-02-23 23:04 波吉国王 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 1 目的: 为了解决回调地狱 setTimeout(() => { console.log('买菜'); }, 1000); setTimeout(() => { console.log('洗菜'); }, 1000); setTimeout(() => { console.log('炒菜'); } 阅读全文
posted @ 2022-02-23 23:04 波吉国王 阅读(81) 评论(0) 推荐(0) 编辑
摘要: let 不能重复声明,块级作用域,没有变量提升 const 大写,赋初值,不能修改,块级作用域,const TEAM=[],对他修改不报错,TEAM地址 解构赋值 let [a, b, c] = [1, 2, 3]; let [a, b, c, d, e] = 'hello'; let [a = 2 阅读全文
posted @ 2022-02-23 23:03 波吉国王 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 1 获得时间 new Date() 缺省参数时,返回的是当前时间 格式 结果 new Date() Thu Feb 03 2022 22:36:39 GMT+0800 (中国标准时间) new Date(1643899334112) Thu Feb 03 2022 22:42:14 GMT+0800 阅读全文
posted @ 2022-02-23 23:02 波吉国王 阅读(81) 评论(0) 推荐(0) 编辑