
vue
qianduan1020
这个作者很懒,什么都没留下…
展开
-
vue出错集
vue3,vue 的报错原创 2022-06-10 10:50:50 · 165 阅读 · 1 评论 -
前端sso单点登录
sso.vue 文件<template> <div></div></template><script>import util from '../../utils/util.js';export default { computed: { code () { return this.$route.query.code; }, }, methods: { setRole (roles) { const isLe原创 2021-12-07 11:15:31 · 816 阅读 · 0 评论 -
拖拽选择距离
使用拖拽插件啊 draggabilly<template> <div class="timeline-container overflow-hidden relative" ref="timelineContainer"> <div class="relative"> <div class="absolute slider left-0 top-0 z-20" ref="slider"> <div class=原创 2021-11-09 14:15:43 · 163 阅读 · 0 评论 -
全局组件的挂载和卸载
live-play.jsimport Vue from 'vue'import LivePlayDialog from '@/components/live-play-dialog.vue' //挂载的组件const PopupBox = Vue.extend(LivePlayDialog) // extend 注册全局let instanceLivePlayDialog.install = function (data) { console.log(data, 222222) in.原创 2021-11-08 17:12:15 · 580 阅读 · 0 评论 -
token过期自动跳转登录页面
1.在响应拦截器中,判断code为401,2.再弹出对话框,3.点确定做退出操作删除token及相关登录信息4.然后跳转登录页面。注意:此时会出现多个对话框,所以添加一个状态变量,如果第一次点击确定把状态变为true,在判断的401的同时判断状态值是否为false,这样就避免出现多个对话框let isRefreshing = falseservice.interceptors.response.use(response => { const code = res.data.code原创 2021-09-13 14:45:32 · 446 阅读 · 0 评论 -
前端导出pdf文件
this.$get(url, {}, { responseType: 'blob' }).then(res => { //创建隐藏的可下载链接 const blob = new Blob([res]); const link = document.createElement('a'); const evt = document.createEvent('HTMLEvents'); evt.initEvent('click',原创 2021-09-13 11:29:58 · 175 阅读 · 0 评论 -
解决 Uncaught (in promise) Error: Navigation cancelled from “/...“ to “/...“ with a new navigation.
报错如下:解决方法:在路由器router里面的index.js里面加上下面这段代码就没事了const originalPush = Router.prototype.pushconst originalReplace = Router.prototype.replaceRouter.prototype.push = function push(location, onResolve, onReject) { if (onResolve || onReject) { return o原创 2021-09-13 11:14:37 · 3364 阅读 · 0 评论 -
防止message弹窗多次出现
this.$message.warn({content:‘该词已添加’,key:‘tips’,duration:2})原创 2021-03-16 15:59:09 · 519 阅读 · 0 评论 -
父组件props传递数据给子组件报错
父组件传递props异步数据到子组件的问题?子组件的插值表达式中显示异步数据的某个属性值报错created获取props的数据报错解决办法:父组件调用子组件中加判断v-if在子组件中用watch监听数据,获取值在methods中定义方法在watch中调用用bus,$emit, on,在父组件中异步获取数据时on, 在父组件中异步获取数据时on,在父组件中异步获取数据时emit传递数据,在子组件中 $on接收父组件传递的数据进行相应的显示。(parent.vue和child.vue必须公用一原创 2020-11-24 10:31:33 · 243 阅读 · 0 评论 -
elementui中table和unpload的坑
elementui项目中的坑上传文件限制大小或个数2.table表头自定义3.query传参数,在页面刷新的时候可能会将query中参数的类型发生转换(如number转string)上传文件限制大小或个数限制的原理是先上传(before-upload)后删除,如果上传限制的同时还用到before-remove的话,用户就可以阻碍删除限制的文件,当用户点了取消删除按钮,限制的文件则还是上传了。这样限制就中return false或true就失效了。解决:在data或computed中添加一个字段flag原创 2020-07-02 15:42:31 · 663 阅读 · 0 评论 -
路由懒加载在开发环境下更新代码很长时间的解决方案
使用babel 的 plugins babel-plugin-dynamic-import-node。它只做一件事就是将所有的import()转化为require(),这样就可以用这个插件将所有异步组件都用同步的方式引入,并结合 BABEL_ENV 这个babel环境变量,让它只作用于开发环境下,在开发环境中将所有import()转化为require(),这种方案解决了之前重复打包的问题,同时对代...原创 2020-04-02 17:14:35 · 519 阅读 · 0 评论 -
利用requier.context()自动构建路由
router文件的index.jsimport Vue from 'vue';import VueRouter from 'vue-router';// import About from './about.routes.js';// import Home from './home.routes.js';Vue.use(VueRouter)const routesList=[]...原创 2019-10-23 10:09:09 · 142 阅读 · 0 评论 -
利用requier.context()在vue中注册全局组件
// 1.在components文件中新建global.js文件import Vue from 'vue';function changA(str) { return str.charAt(0).toUpperCase() + str.slice(1)}const requireComponent = require.context('.', false, /\.vue$/)co...原创 2019-10-22 20:22:35 · 337 阅读 · 0 评论 -
vue中使用better-scroll遇到的问题
安装及引入npm i better-scrollimport BScroll from 'better-scroll'初始化// <div class="wrapper">// <ul class="content">// <li>...</li>// <li>...</li>// ...原创 2019-10-22 17:33:09 · 827 阅读 · 0 评论 -
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available
使用vue-cli3初始化运行项目的时候会出现这样的问题:[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the c...原创 2019-10-21 10:00:24 · 479 阅读 · 0 评论 -
vue中axios请求解决跨域问题
vue的脚手架2和3中解决跨域在src文件里建立api文件夹里有两个文件ajax.jsindex.jsajax.js// 是对axios请求做了一个封装import axios from 'axios';export default function ajax(url, data={},method='GET'){return new Promise((resolve, rej...原创 2019-10-19 21:49:00 · 291 阅读 · 1 评论 -
vue中使用swiper插件遇到的问题
//1. 安装swipernpm i swiper//2.引用import Swiper from "swiper";//下面用不了就用这个 import "swiper/dist/css/swiper.css"; 可以去node_modules--->swiper文件夹里找一下swiper.css的路径import "swiper/css/swiper.css";//3.创建s...原创 2019-10-19 15:54:07 · 956 阅读 · 0 评论 -
解决移动端延迟的问题
在head标签里1.添加viewport meta标签,表示移动端2.引入fastclick.js3.加入js代码片段// vue中添加到默认的index.html的head标签中<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1....原创 2019-10-19 14:30:50 · 192 阅读 · 0 评论 -
安装下载vue脚手架2和3步骤及区别
安装下载vue脚手架2和3步骤及区别安装vue-cli2版本步骤如下:1.下载vue-cli22.vue-cli2安装webpack3.进入项目目录并运行4.打包并运行安装vue-cli3版本步骤如下:1.下载vue-cli32.vue-cli3安装webpack3.进入项目目录并运行4.打包并运行安装vue-cli2版本步骤如下:1.下载vue-cli2npm i -g vue-cli...原创 2019-10-19 10:58:38 · 2205 阅读 · 0 评论