- 博客(48)
- 收藏
- 关注
原创 uniapp <textarea>组件的踩坑
解决办法:把封装成基础组件,dom元素切换时,通过v-if显示隐藏,触发组件onMounted,延迟auto-height赋值。官方人员解释:textarea 的 auto-height 必须要在屏才能计算高度,先展示再赋值。2、使用auto-height属性,安卓真机上,会导致高度异常,1、ios真机上,输入时会触发页面其他点击事件。解决方法:把封装成基础组件,绕过这个bug。
2023-07-27 20:58:45
2383
1
原创 vue.config.js基本配置
const webpack = require("webpack");// const UglifyJsPlugin = require('uglifyjs-webpack-plugin')const isPro = process.env.NODE_ENV === "production" ? true : false;module.exports = { publicPath: "/", // 部署应用时的根路径(默认'/'),也可用相对路径(存在使用限制) outputDir: "d
2021-08-31 16:53:50
424
原创 VSCode 快速生成html代码片段
"!": { "prefix": "!", // 触发的关键字 输入!按下tab键 "body": [ "<!DOCTYPE html>", "<html lang=\"en\">", "<head>", "<meta charset=\"UTF-8\">", "<meta name=\"viewport\" content=\"width=device-width, initi
2021-08-05 15:48:36
363
原创 vue-router的addRoutes()和addRoute()的使用问题
注意:router.addRoutes已废弃:使用 router.addRoute() 代替。addRoutes的使用方法:router.addRoutes(newRoutes)addRoute的使用方法:for (let x of newRoutes) { router.addRoute(x)}官方的解释是 router.addRoute 接受的是一个路由规则,也就是一个对象,或者接受一个字符串和一个对象。...
2021-05-11 10:07:22
7382
3
原创 微信小程序—在线预览二进制流文件
// 请求 下载预约表格 接口 exportExcel (e) { let that = this let id = that.getPageOptions().id let fileName = `【${that.data.holderInfo.nameC}】 ${that.data.bookingInfo.area}-${that.data.productInfo.company}-${that.data.productInfo.plan}` wx.showLoadi
2021-03-29 17:20:51
888
原创 小程序swiper高度自适应
1、wxml部分<block wx:for="{{list}}" wx:key="index"> <view class="list-item-m" style="height: {{imgheights[index]}}rpx"> <!-- 轮播图 S --> <swiper data-idx="{{index}}" bindchange="swiperChangeEv" style="height: {{imgheights[index]}
2020-12-10 10:49:45
305
原创 小程序输入框导致页面整体上移,在获得焦点时固定住页面的解决办法
1、输入框组件设置 adjust-position="{{false}}"2、输入框容器fixed定位,style="bottom: {{bottom}}px"3、如下// 监听input获取焦点 onFocus (e) { let that = this that.setData({ bottom: e.detail.height }) }, // 监听input失去焦点 onBlur (e) { let that = this t
2020-12-07 19:26:16
1797
1
原创 关于小程序输入框文字回车符提交后,返回的数据换行问题
let str = "哈哈哈哈↵测试测试";str = str.replace(/↵/g,"\n");<text>{{str}}</text>tips:str需要在 <text> 标签里
2020-09-08 11:26:01
640
原创 检查小程序版本更新
在app.js里添加以下代码:// 检查小程序版本更新 checkNewVersion: function () { // 检查版本更新 // 获取小程序更新机制兼容 if (wx.canIUse('getUpdateManager')) { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息
2020-09-04 11:22:23
240
原创 vue动态添加权限路由
在做后台系统时一般都会涉及到菜单权限控制的问题,这里的处理是根据后端返回的权限表,生成动态路由来控制权限,话不多说,上代码。
2020-08-24 14:01:11
1907
原创 Base64 转化成 File
// Base64 转化成 FiledataURLtoFile (dataurl, filename) {let arr = dataurl.split(’,’)let mime = arr[0].match(/????.*?);/)[1]let bstr = atob(arr[1])let n = bstr.lengthlet u8arr = new Uint8Array(n)while (n–) {u8arr[n] = bstr.charCodeAt(n)}return new Fi
2020-08-06 11:49:48
274
原创 element-ui实现多级树形结构+复选框表格
效果如下图:代码如下:<template> <div class="role-details inside-base"> <div class="inside-base-main clearfix"> <!-- 中间内容 --> <div class="inside-base-cont"> <div class="role-cont clearfix"> &l
2020-08-05 09:17:44
6106
4
原创 $.ajax下载流文件
<body><div class="wrap"> <div> <p>agent_id:</p> <input type="text" value="" id="agentId"> <p>token:</p> <input type="text" value="" id="token"> </div> <a href="javascri
2020-07-20 14:32:16
2310
原创 WebSocketTest
function WebSocketTest () { var webSocket = null; //判断当前浏览器是否支持WebSocket if ("WebSocket" in window) { alert("您的浏览器支持 WebSocket!"); // 打开一个 web socket var webSocket = new WebSocket("ws://localhost:9998/echo"); //连接发生错误的回调方法 webSocket.onerror
2020-07-20 14:20:39
495
原创 微信小程序--实现下载预览文件并分享
转发:https://developers.weixin.qq.com/community/develop/doc/000e44edfbc438456baad9d895e400
2020-07-15 16:25:04
1757
原创 微信小程序分享文件给好友
1、wxml代码<button class="download" bindtap="openFileEv">打开文件</button>2、js代码// 打开文件 openFileEv () { wx.downloadFile({ url: 'https://download.com/file/xxx.xlsx', // 并非真实链接 success: function (res) { const filePath = res
2020-07-07 17:49:20
4312
原创 在html页面填入字符串,\n换行不起作用,怎么办?
CSS white-space 属性在white-space属性中,有上图几个值可供选择,我们可以在DOM元素中使用white-space: pre-line;这样在html页面填入字符串,\n换行就起作用了。
2020-06-04 17:51:42
14175
原创 win10下解决:sourcee tree 添加 accounts.json无效
在%LocalAppData%\Atlassian\SourceTree\新增accounts.json[ { "$id": "1", "$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity", "Authenticate": true,...
2020-03-05 18:09:05
188
原创 Vue的keep-alive组件,使用include和exclude不生效的问题
官方文档:keep-aliveinclude - 字符串或正则表达式。只有名称匹配的组件会被缓存。exclude - 字符串或正则表达式。任何名称匹配的组件都不会被缓存。max - 数字。最多可以缓存多少组件实例。用法:<keep-alive>包裹动态组件时,会缓存不活动的组件实例,而不是销毁它们。和 <transition> 相似,<keep-aliv...
2019-12-04 11:31:39
1648
原创 vue + axios + element-ui 实现全局Loading(部分接口不要loading,多个请求合并一个loading)
项目中axios和api已分别封装在http.js和api.js里面,代码demo如下:tips:实现是否需要loading,在请求方法里面添加config参数配置实现多个请求合并一个loading,查看http.js里 // 加载函数Loading S => // 加载函数Loading Ehttp.jsimport Vue from 'vue'import axios fr...
2019-11-18 12:41:54
3521
原创 Vue + axios + el-upload组件,实现自定义多文件上传
需求:Vue项目中使用element-ui的el-upload上传文件,由于页面中除了文件上传,还有表单数据需要一起提交,所以不能使用el-upload的默认上传,而官方文档提供了http-request自定义上传方法来覆盖组件默认的上传方式,如下图:所以我们可以在自定义上传方法中,配合使用Axios来提交上传文件需要注意的是:自定义的上传方式就是模拟html表单上传文件,所以我们使用ne...
2019-11-13 16:09:02
2157
原创 Vue项目中全局引入.scss文件
在用vue-cli开发项目的时候,需要全局引入一个公共的.scss文件供每个.vue文件使用,而不需要在每个.vue文件中引入.scss文件步骤一:首先要下载 : sass-resources-loadernpm install sass-resources-loader --save-dev步骤二:在项目build/utils.js里,找到如下图位置修改为:scss: gene...
2019-10-24 15:07:12
1430
原创 Vue项目引入Css预处理 -- Sass
1、安装依赖npm install sass-loader --save-devnpm install node-sass --sava-dev2、在build文件夹下的webpack.base.conf.js的rules里面添加配置{ test: /\.sass$/, loaders: ['style', 'css', 'sass']}3、在.vue文件里修改style标...
2019-10-24 12:34:00
635
原创 Vue中keep-alive配合router-view缓存路由
<!-- template --><keep-alive> <router-view v-if="$router.meta.keepAlive"></router-view></keep-alive><router-view v-if="!$router.meta.keepAlive"></router-v...
2019-09-29 19:13:22
1589
原创 基于vue的图片裁剪组件vue-cropper,配合element-ui组件上传
github地址:https://github.com/xyxiao001/vue-cropper安装:npm install vue-cropper -S
2019-08-30 13:41:33
3594
原创 Vue项目打包时去除console、debugger
在build文件夹下的webpack.prod.conf.js文件里的plugins下面添加:new UglifyJsPlugin({ uglifyOptions: { compress: { warnings: false, `drop_debugger: true, // 打包去除 debugger` `drop_console: true /...
2019-07-30 12:07:51
3889
2
原创 Vue项目中判断用户是否登录的拦截问题
1、在进入页面时,拦截路由进行登录判断,需要进行以下两部分:// 全局路由导航拦截router.beforeEach((to, from, next) => { // ... if (to.path === '/login') { // 如果是登录页面路径,就直接next() next() } else { // 其他页面路径 let token = sessi...
2019-06-14 12:57:15
1943
原创 使用vue-router beforeEach钩子遇到的一些小问题
一、在进入页面时,判断用户未登录,需要跳转到登录页此时路由代码是这样的:// 全局路由导航拦截router.beforeEach((to, from, next) => { // ... let token = sessionStorage.getItem('userToken') // 获取用户登录token if (token === null || token ===...
2019-06-14 11:06:44
5610
2
转载 正则表达式的汉字匹配
本文转自:http://www.cnblogs.com/yitian/archive/2008/11/14/1333569.html这里是几个主要非英文语系字符范围2E80~33FFh:中日韩符号区。收容康熙字典部首、中日韩辅助部首、注音符号、日本假名、韩文音符,中日韩的符号、标点、带圈或带括符文数字、月份,以及日本的假名组合、单位、年号、月份、日期、时间等。3400~4DFFh:中日...
2019-05-21 15:29:34
2336
原创 vue中引入jquery
本文转自:https://blog.youkuaiyun.com/hhy1006894859/article/details/794674451、在项目中安装jquery。npm install jquery --save-dev2、在项目根目录下的build/webpack.base.conf.js文件中:① 先写以下代码var webpack = require("webpack") ②在...
2019-04-25 09:27:35
345
转载 动态生成form表单--post请求进行下载
本文参考:https://www.cnblogs.com/webbest/p/10107697.htmlconst postDownloadFile = (action, param) => { const form = document.createElement('form'); form.action = action; form.method = 'post...
2019-04-17 22:02:10
1028
转载 vue+axios 运用Blob对象实现文件下载
本文转自:https://www.cnblogs.com/yulj/p/8494465.html功能:点击导出按钮,提交请求,下载excel文件;第一步:跟后端童鞋确认交付的接口的response header设置了以及返回了文件流。第二步:修改axios请求的responseType为blob,以post请求为例:复制代码axios({ method: 'post', ...
2019-04-17 17:56:48
6200
1
原创 Axios兼容 IE浏览器
在ie浏览器下,我们会发现axios获取请求数据失败,会报错:vuex requires a Promise polyfill in this browseraxios说是支持ie8+,不过其原理是基于promise之上实现的,所以会有不兼容ie的问题解决方法:1、安装 babel-polyfill2、修改build配置环境为下图或者 直接import然后 npm run dev 重启...
2019-04-17 15:39:46
1882
1
原创 VSCode---background插件
1、以管理员身份运行VS Code,搜索安装background插件2、打开设置,选择扩展中的plugin background,选择在setting.json中编辑3、在setting.json中输入以下代码,修改完后按Ctrl+S保存,会提示重启VS Code,点击确定后即可完成修改// background相关配置 Start "background.useDefault": ...
2019-04-11 13:16:20
14051
10
原创 VSCode 快速生成vue代码片段
第一步、打开vscode,找到用户代码片段,选择vue.json文件打开,如下图第二步、将以下代码复制粘贴到vue.json里面,保存"Print to console": { "prefix": "vue", "body": [ "<template>", " <div>\n", " </d...
2019-04-10 09:36:23
5998
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人