随笔分类 - JavaScript
摘要:axios 通过async和await实现同步 function getPage(menuId, url) { // 这里要有 return return this.$http.get(url, { params: { menuId: menuId } }).then((response) => {
阅读全文
摘要:怎么在Vue中使用axios组件: 通过npm安装axios npm i axios 在 src/main.js中导入该组件 import axios from 'axios' axios常用请求 GET : // 为给定 ID 的 user 创建请求 axios.get('/user?ID=123
阅读全文
摘要:怎么在Vue项目中使用Element组件: 通过npm下载Element组件 npm i element-ui -S 在 src/main.js 中导入该组件 // 引入相关JS文件 import Element from 'element-ui' // 引入相关CSS文件 import 'elem
阅读全文
摘要:vue-cli 基本使用 1、全局安装vue-cli 安装 npm install -g @vue/cli 2、通过vue创建一个项目 vue create hello-world 3、项目运行 cd hello-world npm run serve 4、把项目编译成静态网页 注意:这里可能会出现
阅读全文
摘要:JS 可以通过 for in 的方法来遍历对象 for(item in obj){ console.log(obj[item]); console.log(item);}
阅读全文
摘要:通过 Object.keys(json_obj).length可以获取对象的长度
阅读全文
摘要:通过Jquery中的change函数可以用来检测option中修改后的值; 直接使用JavaScript中的onchange在对改变后的值进行用$(this)取值好像有点问题!! <select name="" id="" style="padding-right: 45px;" class="ch
阅读全文
摘要:原因:未引入 bootstrap3 的JS; 解决办法:引入 bootstrap3 的JS文件
阅读全文
摘要:Express Express 安装及hello world 安装: Hello World: 通过 express generator创建express项目 安装 express generator到项目目录的 node_modules 中: 创建 express 项目 安装依赖 cd 到项目中,
阅读全文
摘要:关键代码: // 将base64 的数据弄到form表单中 // 将base64 的代码转化为二进制 let bytes = window.atob(crop_base64.split(',')[1]); let ab = new ArrayBuffer(bytes.length); let ia
阅读全文
摘要:通过 window.location.href 获取网页的URL
阅读全文
摘要:先上效果图: 实现的步骤: 第一步:页面的准备,需要使用 mui 的search控件,以及自己准备一个供提示 DIV,这里我贴一下我的页面代码,主要是通过 onkeyup 事件来检查什么时候进行数据的提交,不过如果不对该事件加以控制会向后台发送没有意义的数据,加大服务器的压力,那么我这里的做法是先简
阅读全文
摘要:wx.setNavigationBarTitle() 动态设置页面标题 wx.setNavicationBarColor() 动态设置页面标题的颜色和背景等 样式: 示例代码: wx.setNavigationBarTitle({ title: '当前页面' }) wx.setNavigationB
阅读全文
摘要:wx.showActionSheet() 选择菜单 样式截图: 示例代码: wx.showActionSheet({ itemList: ['A', 'B', 'C'], success (res) { console.log(res.tapIndex) }, fail (res) { consol
阅读全文
摘要:wx.showLoading() 显示加载框,需要主动加 wx.hideLoading() 才能隐藏 样式: 示例代码: wx.showLoading({ title: '加载中', }) setTimeout(function () { wx.hideLoading() }, 2000)
阅读全文
摘要:wx.shoModal() 模态弹窗 样式: 示例代码: wx.showModal({ title: '提示', content: '这是一个模态弹窗', success (res) { if (res.confirm) { console.log('用户点击确定') } else if (res.
阅读全文
摘要:wx.showToast()样式: 示例代码: wx.showToast({ title: '成功', icon: 'success', duration: 2000 })
阅读全文
摘要:getLauchOprionsSync() 作用:获取小程序启动时的参数 使用位置:JS文件的任意位置 实例代码: console.log(wx.getLaunchOptionsSync());
阅读全文
摘要:参考资料 clipboard 简介: clipboard 是一个很小的JS框架,我们只需要通过 script 标签将其引入,就可以使用它提供的复制功能。 方法一:将待复制的值放在 data-clipboard-text 中,当点击该标签的时候就会将该值复制到剪贴板 <script src="http
阅读全文
摘要:echarts.init(document.getElementById(id)).setOption({ backgroundColor: '#2c343c', // 背景颜色 textStyle: { color: 'rgba(255, 255, 255, 0.3)', // 文本颜色 font
阅读全文