
vue
cuter、
这个作者很懒,什么都没留下…
展开
-
nuxt探活接口
测试人员需要探活接口,用于检测网站serverMiddleWare/ping.js下export default function (req, res, next) { res.writeHead(200, { "content-type": "text/plain; charset=utf-8" }); res.end("pong"); } nuxt.config.js下 serverMiddleware: [ { path:'原创 2021-12-08 17:02:06 · 1036 阅读 · 0 评论 -
axios的进一步封装
import axios from 'axios'let instance=axios.create({baseURL:'xxxxxx',timeout:5000})//请求拦截instance.interceptors.request.use(config=>{//请求拦截要处理的内容return config},err=>{console.error('请求失败',err)})//响应拦截instance.interceptors.response.use(res=原创 2021-08-29 21:59:06 · 154 阅读 · 0 评论 -
时间戳的格式化
//格式化创建时间Vue.filter('dataFormatCommonTime', function(originVal) { const dt = new Date(originVal) const y = dt.getFullYear() const m = (dt.getMonth() + 1 + '').padStart(2, '0') const d = (dt.getDate() + '').padStart(2, '0') const hh = (dt.getHour原创 2021-08-29 10:44:43 · 364 阅读 · 0 评论 -
vue插槽
插槽作用:让父组件可以向子组件指定位置插入html结构,也是一种组件间通信的方式,适用于 父组件 ===> 子组件 。分类:默认插槽、具名插槽、作用域插槽使用方式:默认插槽:父组件中: <Category> <div>html结构1</div> </Category>子组件中: <template> <div>原创 2021-08-24 14:54:14 · 249 阅读 · 0 评论 -
Vue2基础
关于不同版本的Vuevue.js与vue.runtime.xxx.js的区别:vue.js是完整版的Vue,包含:核心功能 + 模板解析器。vue.runtime.xxx.js是运行版的Vue,只包含:核心功能;没有模板解析器。因为vue.runtime.xxx.js没有模板解析器,所以不能使用template这个配置项,需要使用render函数接收到的createElement函数去指定具体内容。vue.config.js配置文件使用vue inspect > output.转载 2021-08-24 14:05:59 · 150 阅读 · 0 评论 -
vue脚手架配置代理
vue脚手架配置代理方法一 在vue.config.js中添加如下配置:devServer:{ proxy:"http://localhost:5000"}说明:优点:配置简单,请求资源时直接发给前端(8080)即可。缺点:不能配置多个代理,不能灵活的控制请求是否走代理。工作方式:若按照上述配置代理,当请求了前端不存在的资源时,那么该请求会转发给服务器 (优先匹配前端资源)方法二 编写vue.config.js配置具体代理规则:module.exports = { de原创 2021-08-24 14:04:24 · 341 阅读 · 0 评论 -
Vue封装的过度与动画
作用:在插入、更新或移除 DOM元素时,在合适的时候给元素添加样式类名。写法:准备好样式:元素进入的样式:v-enter:进入的起点v-enter-active:进入过程中v-enter-to:进入的终点元素离开的样式:v-leave:离开的起点v-leave-active:离开过程中v-leave-to:离开的终点 /* 进入的起点、离开的终点 */ .hello-enter,.hello-leave-to{ transform: transl..原创 2021-08-24 14:03:23 · 148 阅读 · 0 评论 -
Vuex改变网站主题
import Vuex from 'vuex'//该文件用于创建vue的storeimport Vue from 'vue'Vue.use(Vuex)//准备state 存储数据const state = { regUserInfo: {}, themBgColor: '#5698c3', themBasetColor: '#3170a7'}const getters = { regUserInfo: state => state.regUserInfo, themB原创 2021-08-21 18:34:59 · 147 阅读 · 0 评论 -
Vue的路由守卫前置和后置
路由配置const router = new VueRouter({ mode: 'history', routes: [ { path: '/', redirect: '/blog/welcome' }, { path: '*', name: 'NotFound', component: NotFound, meta: { isAuth: false, title: '页面找不到' } },原创 2021-08-20 22:55:26 · 404 阅读 · 0 评论 -
Vue生命周期
/*常用的生命周期钩子: 1.mounted: 发送ajax请求、启动定时器、绑定自定义事件、订阅消息等【初始化操作】。 2.beforeDestroy: 清除定时器、解绑自定义事件、取消订阅消息等【收尾工作】。关于销毁Vue实例 1.销毁后借助Vue开发者工具看不到任何信息。 2.销毁后自定义事件会失效,但原生DOM事件依然有效。 3.一般不会在beforeDestroy操作数据,因为即便操作数据,也不会再触发更新流程了。*/ beforeCreate.原创 2021-08-04 22:15:45 · 253 阅读 · 0 评论