08 2021 档案

摘要:export function shuffle(arr) { let _arr = arr.slice() for (let i = 0; i < _arr.length; i++) { const j = _getRandomNumber(0, i) const temp = _arr[i] _a 阅读全文
posted @ 2021-08-29 20:38 吴小明- 阅读(331) 评论(0) 推荐(0) 编辑
摘要:方法一: 1、data中定义timer变量 data() { return { timer: null } } 2、在使用定时器时将定时器赋值给timer methods: { toggleImg() { this.timer = setInterval(() => { this.currentIn 阅读全文
posted @ 2021-08-29 20:01 吴小明- 阅读(2771) 评论(0) 推荐(0) 编辑
摘要:根据windows日历,获取当前周,以及当前周的前2周和后4周,共7周的日期范围 export function getFormatDate(serverDate) { let list = [] // 二维数组 let formatDate = function (date, days) { le 阅读全文
posted @ 2021-08-27 14:27 吴小明- 阅读(646) 评论(0) 推荐(0) 编辑
摘要:1、作为事件对象【原生事件】 <button @click="handleClick">按钮</button> <el-button @click="handleClick($event)">按钮</el-button> methods: { handleClick(e) { console.log 阅读全文
posted @ 2021-08-26 18:03 吴小明- 阅读(964) 评论(0) 推荐(0) 编辑
摘要:1、utils/utils.js const namespace = 'mall' export function setItem(key, value) { let storage = window.localStorage.getItem(namespace) storage = storage 阅读全文
posted @ 2021-08-26 11:09 吴小明- 阅读(275) 评论(0) 推荐(0) 编辑
摘要:export const quertObject = (url) => { const queryString = url.split('?')[1] const obj = {} const arr = queryString.split('&') for (let i = 0; i < arr. 阅读全文
posted @ 2021-08-25 23:38 吴小明- 阅读(105) 评论(0) 推荐(0) 编辑
摘要:当使用elementUI的按钮组件时 <el-button @click="handleClick1">按钮一</el-button> <el-button @click="handleClick2">按钮二</el-button> <el-button @click="handleClick3"> 阅读全文
posted @ 2021-08-25 22:02 吴小明- 阅读(999) 评论(0) 推荐(0) 编辑
摘要:定义Child组件: <template> <transition name="slide"> <div id="child" v-show="isShow"> <h1>子组件</h1> <button @click="isShow=false">按钮</button> </div> </trans 阅读全文
posted @ 2021-08-25 20:37 吴小明- 阅读(86) 评论(0) 推荐(0) 编辑
摘要:动态面包屑效果: 1、当路由为/home时,面包屑只展示一级 2、当路由为/home/manage时,面包屑显示一级和二级 3、当路由为/home/manage/list或/home/manage/test时,面包屑显示一级、二级、三级 实现: 1、components/BreadCrumb.vue 阅读全文
posted @ 2021-08-25 15:37 吴小明- 阅读(1401) 评论(0) 推荐(0) 编辑
摘要:相同点: 1、都是用来放静态资源的 2、如果资源在html中使用,都是可以的 <img src="../../../assets/images/002.jpg"> <img src="../../../../static/images/002.jpg"> 3、资源通过import引入,都可以在htm 阅读全文
posted @ 2021-08-24 20:06 吴小明- 阅读(217) 评论(0) 推荐(0) 编辑
摘要:<template> <div class="star"> <span class="star-item on"></span> <span class="star-item off"></span> <span class="star-item half"></span> <hr> <span c 阅读全文
posted @ 2021-08-23 23:28 吴小明- 阅读(1952) 评论(0) 推荐(0) 编辑
摘要:<ul id="list"> <li id="li1">项目一</li> <li>项目二</li> <li>项目三</li> <li>项目四</li> </ul> const list = document.getElementById('list') const li1 = document.ge 阅读全文
posted @ 2021-08-23 20:20 吴小明- 阅读(101) 评论(0) 推荐(0) 编辑
摘要:<ul id="list"></ul> const ul = document.getElementById('list') const fragment = document.createDocumentFragment() for (let i = 0; i < 5; i++) { const 阅读全文
posted @ 2021-08-22 23:04 吴小明- 阅读(35) 评论(0) 推荐(0) 编辑
摘要:一、async函数返回值都是Promise对象 二、promise.then 成功的情况 对应await 三、promise.catch 失败的情况 对应try…catch 一、async函数返回值都是Promise对象 1、返回值不是promise对象,那么新promise的状态为fullfill 阅读全文
posted @ 2021-08-22 20:19 吴小明- 阅读(111) 评论(0) 推荐(0) 编辑
摘要:结论: 1、then 正常返回时,Promise的状态为fulfilled 报错时,Promise的状态为rejected 2、catch 正常返回时,Promise的状态为fullfilled 报错时,Promise的状态为rejected 当状态为成功时: const p = Promise.r 阅读全文
posted @ 2021-08-22 18:16 吴小明- 阅读(588) 评论(0) 推荐(0) 编辑
摘要:<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script> <script> const ID_BASE_URL = 'https://jsonplaceholder.typicode.com/to 阅读全文
posted @ 2021-08-22 16:58 吴小明- 阅读(53) 评论(0) 推荐(0) 编辑
摘要:class Person { constructor(name) { this.name = name } publicFn() { console.log('公共方法') } } class Student extends Person { constructor(name, score) { / 阅读全文
posted @ 2021-08-20 17:37 吴小明- 阅读(74) 评论(0) 推荐(0) 编辑
摘要:dom结构: <h1><b>h1</b></h1> <h2><b>h2</b></h2> <h3><b>h3</b></h3> <h4><b>h4</b></h4> <h5><b>h5</b></h5> <h6><b>h6</b></h6> css: h1 > b, h2 > b, h3 > 阅读全文
posted @ 2021-08-20 11:10 吴小明- 阅读(129) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content 阅读全文
posted @ 2021-08-19 21:41 吴小明- 阅读(76) 评论(0) 推荐(0) 编辑
摘要:1、v-html和v-text(简写:{{}})相比,可以识别字符串中的标签 data() { return { html1: '<p>HTML1</p>' } } <p v-html="html1"></p> <p v-text="html1"></p> <p>{{html1}}</p> 结果: 阅读全文
posted @ 2021-08-19 11:57 吴小明- 阅读(1721) 评论(0) 推荐(0) 编辑
摘要:Sticky Footer:页脚footer永远在页面的底部,内容不够长时footer停留在底部,内容撑满时将footer往下挤,footer仍然停留在底部。 实现方式: 1、利用绝对定位和padding-bottom .container { position: relative; min-hei 阅读全文
posted @ 2021-08-17 17:55 吴小明- 阅读(112) 评论(0) 推荐(0) 编辑
摘要:/* 第一种方法:设置父容器的行高,子容器需要设置为行内块 */ .box1 { width: 200px; height: 200px; line-height: 200px; background: rgb(164, 214, 179); } .box1 span { display: inli 阅读全文
posted @ 2021-08-17 15:29 吴小明- 阅读(71) 评论(0) 推荐(0) 编辑
摘要:block formatting context 块级格式化上下文 形成独立的渲染区域,内部元素的渲染不会影响外界 形成BFC的条件: 浮动元素 float不是none 绝对定位元素 position为absolute或fixed 块级元素的overflow不为visible flex元素 inli 阅读全文
posted @ 2021-08-16 20:12 吴小明- 阅读(20) 评论(0) 推荐(0) 编辑
摘要:margin-top 元素向上拖拽 margin-left 元素向左拖拽 margin-bottom 元素本身不变,下边元素上移 margin-right 元素本身不变,右边元素左移 阅读全文
posted @ 2021-08-16 19:49 吴小明- 阅读(56) 评论(0) 推荐(0) 编辑
摘要:如果想在命令行输入qq来打开qq软件 这样是不行的,需要进入到qq软件所在的目录 但是想要在任何地址下输入qq都可以打开qq软件,就需要设置环境变量了 【此电脑】-【右键】-【属性】-【高级系统设置】-【环境变量】-【path】双击-【新建】-粘贴qq软件所在地址 重启命令行,此时在任何目录下都可以 阅读全文
posted @ 2021-08-14 21:04 吴小明- 阅读(706) 评论(0) 推荐(0) 编辑
摘要:hash: <button id="myBtn">按钮</button> <script> // 监听hash的变化:手动去改路由、浏览器前进后退、点击事件更改hash window.onhashchange = (e) => { console.log('老url', e.oldURL) cons 阅读全文
posted @ 2021-08-12 21:19 吴小明- 阅读(70) 评论(0) 推荐(0) 编辑
摘要:动态组件component标签是vue的一个内置组件,通过动态地设置is属性,渲染出对应的组件 使用方法: 1、components/MyText.vue: <template> <div> 文本组件 </div> </template> components/MyImage.vue: <templ 阅读全文
posted @ 2021-08-12 20:20 吴小明- 阅读(710) 评论(0) 推荐(0) 编辑
摘要:1、store/index.js: import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { buttonPermission: { add: true, 阅读全文
posted @ 2021-08-10 22:27 吴小明- 阅读(326) 评论(0) 推荐(0) 编辑
摘要:定义一个Title组件,在使用的时候,通过父组件传值level去定义这个title是h1~h6 1、components/Title.vue: <template> <h1 v-if="level 1"> <a href=""> <slot></slot> </a> </h1> <h2 v-else 阅读全文
posted @ 2021-08-10 21:57 吴小明- 阅读(54) 评论(0) 推荐(0) 编辑
摘要:inheritAttrs和$attrs的作用: 当需要将父组件的props传递到子组件中,而子组件的需要接收到props的节点有父级容器,那么就需要用到这两个属性。 将inheritAttrs设置为false,在子组件需要接收props的节点上加上 v-bind='$attrs' 如果父组件中在子组 阅读全文
posted @ 2021-08-10 18:00 吴小明- 阅读(190) 评论(0) 推荐(0) 编辑
摘要:1、vue-ssr/index.template.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge 阅读全文
posted @ 2021-08-10 11:42 吴小明- 阅读(639) 评论(0) 推荐(0) 编辑
摘要:客户端渲染:前端去服务端获取数据,自己生成dom 服务端渲染:服务端生成dom返回给前端,有利于seo优化 客户端渲染: 服务端渲染: 利用vue-server-renderer渲染一个vue实例: 1、vue-ssr文件夹执行 npm init -y 安装所需插件:npm i vue vue-se 阅读全文
posted @ 2021-08-10 10:24 吴小明- 阅读(306) 评论(0) 推荐(0) 编辑
摘要:1、Live Server 实时编译html文件,很香的 2、Bracket Pair Colorizer 将括号的颜色区分开来,看着就很爽 3、Vetur 代码补全、语法高亮、格式化等 4、Vue VSCode Snippets 代码补全 5、Community Material Theme 更换 阅读全文
posted @ 2021-08-09 20:12 吴小明- 阅读(251) 评论(0) 推荐(0) 编辑
摘要:1、store/index.js: import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { isLogin: false }, mutations: { 阅读全文
posted @ 2021-08-09 19:44 吴小明- 阅读(481) 评论(0) 推荐(0) 编辑
摘要:作用:将ui组件转为js组件 利用Vue.extend()封装一个toast组件 1、components/MyToast/index.vue <template> <div class="container" v-if="show"> <div>{{ text }}</div> </div> </ 阅读全文
posted @ 2021-08-08 22:19 吴小明- 阅读(374) 评论(0) 推荐(0) 编辑
摘要:views/cityDetail.vue: <template> <div class="city-detail">{{$route.params.id}}</div> </template> <style> .city-detail{ height: 1500px; line-height: 50 阅读全文
posted @ 2021-08-06 22:08 吴小明- 阅读(409) 评论(0) 推荐(0) 编辑
摘要:给当前路由加上active类名高亮显示: <template> <div id="app"> <router-link to='/' active-class="active">首页</router-link> | <router-link :to="{name:'about'}" active-c 阅读全文
posted @ 2021-08-06 21:08 吴小明- 阅读(2155) 评论(1) 推荐(1) 编辑
摘要:redirect和alias都是可以将一个地址匹配到想要去到的路由 redirect: { path: '/a', redirect: '/about' } 如果访问 /a 会跳转到 /about alias: { path: '/about', name: 'about', component: 阅读全文
posted @ 2021-08-06 20:30 吴小明- 阅读(208) 评论(0) 推荐(0) 编辑
摘要:命名路由: { path: '/about', name: 'about', component: About } 作用: 1、路由跳转 this.$router.push({ name: 'about' }) 2、路由重定向 { path: '/a', redirect: { // path: ' 阅读全文
posted @ 2021-08-06 20:16 吴小明- 阅读(1008) 评论(0) 推荐(0) 编辑
摘要:使用动态路由: views/Home.vue: <template> <div>Home</div> </template> views/User.js: <template> <div> 当前用户id:{{id}} </div> </template> <script> export defaul 阅读全文
posted @ 2021-08-06 19:35 吴小明- 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Father.vue: <script> import Child from './Child' export default { beforeCreate() { console.log('父组件 beforeCreate') }, created() { console.log('父组件 cre 阅读全文
posted @ 2021-08-06 19:01 吴小明- 阅读(1847) 评论(0) 推荐(2) 编辑
摘要:<body> <div id="app"> <p>{{message}}</p> </div> <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.js"></script> <script> new Vue({ el: '#a 阅读全文
posted @ 2021-08-06 17:28 吴小明- 阅读(122) 评论(0) 推荐(0) 编辑
摘要:自定义一个TabBar组件: <template> <div class="tab-bar"> <div v-for="(item,index) in tabList" :key="index" :class="['common',{active:currentIndex index}]" @cli 阅读全文
posted @ 2021-08-06 16:55 吴小明- 阅读(70) 评论(0) 推荐(0) 编辑
摘要:异步组件和路由懒加载的原理比较像,路由懒加载是将router.js中的路由通过懒加载的方式引入进来从而提升性能,异步组件是那些没有当做路由去使用的组件,如果需要提升这部分组件加载的性能,需要将它的引入方式由同步改为异步。 1、定义一个List.vue: <template> <div>这是一个列表的 阅读全文
posted @ 2021-08-06 16:11 吴小明- 阅读(491) 评论(0) 推荐(0) 编辑
摘要:1、安装: npm install vue-awesome-swiper@3 --save-dev 我的版本是: "vue": "^2.6.11" "vue-awesome-swiper": "^3.1.3" 2、使用: <template> <div class="recommendPage"> 阅读全文
posted @ 2021-08-06 14:47 吴小明- 阅读(1609) 评论(0) 推荐(0) 编辑
摘要:MyButton.vue: <template> <button :class="['my-btn',btnClass]"> <slot name='btnText'></slot> </button> </template> <script> export default { props: { b 阅读全文
posted @ 2021-08-05 21:35 吴小明- 阅读(326) 评论(0) 推荐(0) 编辑
摘要:<template> <div id="app"> <h1>axios拦截器</h1> <button @click="handleClick">按钮</button> <p>{{title}}</p> <div v-if="loading">loading...</div> </div> </te 阅读全文
posted @ 2021-08-05 21:17 吴小明- 阅读(78) 评论(0) 推荐(0) 编辑
摘要:<li v-for="(item,index) in list" :key="index" class="common" :class="index currentIndex?'active':''">{{item}}</li> <li v-for="(item,index) in list" :k 阅读全文
posted @ 2021-08-05 21:02 吴小明- 阅读(551) 评论(0) 推荐(0) 编辑
摘要:[].forEach.call($$("*"),function(a){ a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) }) 阅读全文
posted @ 2021-08-05 17:54 吴小明- 阅读(41) 评论(0) 推荐(0) 编辑
摘要:function star(rate){ const star='★★★★★☆☆☆☆☆' return star.slice(5-rate,10-rate) } 阅读全文
posted @ 2021-08-05 17:50 吴小明- 阅读(57) 评论(0) 推荐(0) 编辑
摘要:扩展运算符的剩余参数,如果想删除对象中的某个属性,这是一个思路 可以对原对象中的字段重新赋值,以及添加一个新的字段 const obj = { name: 'xx', age: 12 } const o = { ...obj, name: 'yy', hobby: 'ss' } // 重写name, 阅读全文
posted @ 2021-08-05 17:11 吴小明- 阅读(1057) 评论(0) 推荐(0) 编辑
摘要:利用对象对数组的每一项进行解构,可以方便地获取数组的第n个值 阅读全文
posted @ 2021-08-05 16:39 吴小明- 阅读(273) 评论(0) 推荐(0) 编辑
摘要:const flatten = (arr, depth = 1) => depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), []) : arr.reduce((a, v) 阅读全文
posted @ 2021-08-05 16:21 吴小明- 阅读(63) 评论(0) 推荐(0) 编辑
摘要:var cars = ['BMW','Benz', 'Benz', 'Tesla', 'BMW', 'Toyota']; var carsObj = cars.reduce(function (obj, name) { obj[name] = obj[name] ? ++obj[name] : 1; 阅读全文
posted @ 2021-08-05 16:10 吴小明- 阅读(44) 评论(0) 推荐(0) 编辑
摘要:将数组中的值翻倍,再输入大于50的数: const numbers = [10, 20, 30, 40]; const doubledOver50 = numbers.reduce((finalList, num) => { num = num * 2; if (num > 50) { finalL 阅读全文
posted @ 2021-08-05 16:07 吴小明- 阅读(182) 评论(0) 推荐(0) 编辑
摘要:const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`) 阅读全文
posted @ 2021-08-05 15:59 吴小明- 阅读(39) 评论(0) 推荐(0) 编辑
摘要:适用于只需要执行一次的代码 阅读全文
posted @ 2021-08-05 15:28 吴小明- 阅读(120) 评论(0) 推荐(0) 编辑
摘要:1、方法一:定义临时变量 2、方法二:利用数组的解构(不需要第三个变量) 阅读全文
posted @ 2021-08-05 11:03 吴小明- 阅读(78) 评论(0) 推荐(0) 编辑
摘要:创建一个HelloWorld组件: <script> import Test from '@/components/Test' export default { props: { tag: String }, data() { return { arr: ['小王', '小明', '小红'] } } 阅读全文
posted @ 2021-08-02 17:46 吴小明- 阅读(447) 评论(0) 推荐(0) 编辑
摘要:1、通过改变父组件中的状态,从而改变兄弟组件的状态 Parent.vue: <template> <div> <h1>父组件</h1> <p>{{name}}</p> <Child1 :name='name' @child1Click='name = $event' /> <Child2 :name 阅读全文
posted @ 2021-08-02 16:38 吴小明- 阅读(819) 评论(0) 推荐(0) 编辑
摘要:1、props+$emit Parent.vue: <template> <div> <h1>父组件</h1> <p>{{message}}</p> <Child :message='message' @messageChange='message=$event' /> </div> </templ 阅读全文
posted @ 2021-08-01 00:29 吴小明- 阅读(58) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示