WishMeLz

生活其实很有趣

分类 Vue 下的文章

粘贴图片 ctrl+v

document.addEventListener("paste", function (event) { var isChrome = false; if (event.clipboardData || event.originalEvent) { //某些chrome版本使用的是event.originalEvent var clipboardData = event.clipboardData || event.originalEvent.clipboard...

Vue axios返回文件流

responseType:"blob", 请求接口的时候加上 let blob = new Blob([res], { type: "application/vnd.ms-excel", }); let url = window.URL.createObjectURL(blob); let link = document.createElement("a"); link.download = 'zz.xlsx' link....

OSS分片式上传文件

Vuenpm i ali-oss配置oss.js import OSS from 'ali-oss' const client = new OSS({ region: 'oss-cn-hangzhou', accessKeyId: '---', accessKeySecret: '---', bucket: '---' }) export default client使用 <div v-loading.fullscreen.lock="fullscreenLoading" :el...

elementui resetFields属性未定义

我目前遇到的情况是  this.$refs["ruleForm"].resetFields(); 提示未定义没有这个方法。但是我第二天重新打开项目就又好了。当时报错解决方法是this.$nextTick(() => { this.$refs["ruleForm"].resetFields(); });

Vue路由跳转

1. router-link2. this.$router.push()3. this.$router.replace() (用法同push)4. this.$router.go(n)router-link<router-link :to="{name:'home'}"> <router-link :to="{path:'/home'}"> <router-link :to="{name:'home', params: {id:1}}"> 类似于post,第一次有效,刷新就消失 <router-link :t...

ElementUI

表单验证// 整个表单验证 this.$refs.dialogRef.validate(()=>{}); // 单个字段 code是字段 this.$refs.dialogRef.validateField('code',()=>{})表单验证rulerules:{ code: [ { required: true, message: "请输入商品编码", trigger: "blur" }, { min: 1, max: 2...

Electron-vue

需要运行环境和打包程序 npm i -g electron npm i -g electron-builder 项目安装 vue init simulatedgreg/electron-vue my-project其中--platform是配置打包成什么平台的安装文件,下面是可选的值win系统: win或者win32,即--platform=win或者--platform=win32mac系统:mac或者darwin,即--platform=mac或者--platform=darwinLinux系统:linux, 即--platform=linu...

Vue中EXCEL的导入导出

import FileSaver from 'file-saver' import XLSX from 'xlsx'导入 <el-upload class="upload-demo" drag action="https://jsonplaceholder.typicode.com/posts/" multiple accept=".xlsx" :on-exceed="exceed" :limit="1" :on-remove="remove...

Vue截图

https://www.npmjs.com/package/vue-cropper/v/0.4.7npm install vue-cropper

Vue打印

在vue中使用浏览器的打印功能npm install vue-print-nb import Print from 'vue-print-nb' Vue.use(Print) 第一种: <div id="printTest" >      <h1>WISHMELZZZZ</h1> </div> <button v-print="'#printTest'">打印</button> 第二种: <button v-print="printObj">Print local range</bu...

Vue反向代理

module.exports = { devServer: { proxy: { "/api":{ //项目中的接口 target:"http://xxx.com", // 对应的反向代理的网址 pathRewrite:{ "^/api":"/api" //对应的接口 } } } }

Vue的地图插件vue-amap

https://github.com/ElemeFE/vue-amap使用配置 npm i vue-amap import VueAMap from 'vue-amap'; Vue.use(VueAMap); VueAMap.initAMapApiLoader({ // 高德的key key: 'be2262deadf45267aed6f6e7rty3ba0', // 插件集合 plugin: [ "AMap.Autocomplete", //输入提示插件 "AMap.PlaceSearch", //POI搜索...

Vue监听器

watch:{ // 参数一:修改后的值; // 参数二:修改之前的值 参数名字:function(newValue,oldValue){ // 操作 } }比如监听每次跳转的路由watch:{ $route(to,from){ console.log(to.path); } }, OR watch: { $route: { handler: function(val, oldVal){ console.log(val); }, // 深度观察监听 ...