![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
vue
张景源
这个作者很懒,什么都没留下…
展开
-
前端跨域问题
什么是跨域问题?跨域问题,即浏览器报 Error: Access to XMLHttpRequest at ‘http://example1.com’ from origin ‘http://example2.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. 这个错误。这是因为:处于安全原因,浏览器会限制由脚本发起的原创 2021-10-08 04:25:24 · 291 阅读 · 0 评论 -
使用 appendChild 添加 SVG 元素不生效
在使用 SVG 时,需要使用 appendChild 来添加元素。但是如下的写法是不生效的:let newElement = document.createElement('rect');newElement.setAttribute('fill','orange');newElement.setAttribute('width','200');newElement.setAttribute('height','200');document.getElementById('svg-drawing原创 2021-07-23 11:33:13 · 1271 阅读 · 1 评论 -
2021 前端校招面试知识点(八股文)整理
1. JavaScript基本数据类型 (7种)this 的指向 (new, 隐式绑定, 显式绑定)Function 的 call, apply, bind 方法Promise, eventloop, 宏任务和微任务闭包 (概念, 用途, 手写)原型链继承 (extends, 原型链继承, 构造函数继承, 组合继承, 寄生组合继承)深拷贝和浅拷贝事件冒泡/捕获, 事件委托, 阻止冒泡, 哪些事件不能冒泡sort() 的复杂度2. 浏览器回流和重绘http 缓存, 协商缓存c原创 2021-04-12 14:06:55 · 12149 阅读 · 0 评论 -
[Mapbox v2] y is not defined / _createClass is not defined
在 React 或 Vue 使用 Mapbox GL JS v2 时出现了如下的错误:这是 Babel 的转译所导致的(Github 中的 Issue:Uncaught ReferenceError: _createClass is not defined (after transpiling with Babel))可以通过设置 webpack , 用 ! 来禁用所有 loaders 来避免,即,在 import 时在 mapbox-gl 前加一个 ‘!’(用上一行的 // eslint-d原创 2021-03-24 18:13:25 · 1280 阅读 · 1 评论 -
Vue 报错 Unexpected side effect in “...“ computed property
Vue 的 计算属性 (computed) 中应当仅包含用于返回值的计算,不应该包含 DOM操作,修改外部变量,异步操作 等。这些操作应该在 侦听器 (watch) 中实现原创 2021-01-27 11:28:46 · 18865 阅读 · 3 评论 -
Axios 取消前一次请求
在对一些按钮点击或者输入事件绑定API请求的时候,当点击、输入过快时,可能出现后一次请求会比前一次请求先到达的情况,导致页面显示的信息没有更新到最后一个请求的结果。对于这种情况,Axios 提供了 cancel token,我们可以用它来实现:在发送后一个请求的时候,终止前一个请求的回调。Axios 的 cancel token 文档代码如下:import axios from 'axios'const CancelToken = axios.CancelToken;let cancel =原创 2021-01-18 16:36:42 · 2520 阅读 · 0 评论 -
v-charts 报错: Cannot read property ‘scale‘ of undefined
是 echarts 的版本问题,可以npm remove echarts再指定安装 echarts 4.9 版本npm install echarts@4.9.0即可解决问题原创 2021-01-11 15:56:48 · 862 阅读 · 1 评论 -
Canvas 获取点击事件的相对位置
function handleClick(e){ myCanvas = document.getElementById("myCanvas") const localXY = { x: e.clientX - myCanvas.getBoundingClientRect().left y: e.clientY - myCanvas.getBoundingClientRect().top }}原创 2021-01-07 11:59:43 · 1334 阅读 · 0 评论 -
Vue CLI 的 env 文件中定义的环境变量不生效
自定义的变量必须以 VUE_APP_ 开头官方文档:https://cli.vuejs.org/zh/guide/mode-and-env.html#环境变量原创 2020-12-30 15:41:36 · 6267 阅读 · 1 评论 -
向 Vuex 的 Actions 中的方法添加回调
Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式。它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化。在 Vuex 中,我们会使用 Actions 进行一些异步操作,例如 API 请求。在许多情况下,我们需要对这样的操作添加回调,在此,我以登录提示为例介绍三种方法:第一种(不推荐)App.vuemethods: { ...mapActions([ 'login' ]), logSuccess(){ cons原创 2020-12-23 11:46:27 · 2077 阅读 · 0 评论 -
Element Table 使用后端排序写法
html中: <el-table :data="tableData" @sort-change="sortChange" > <el-table-column prop="date" label="日期" sortable="custom" width="180"> </el-table-column> </el-table>motheds中:methods:原创 2020-09-16 13:50:07 · 988 阅读 · 0 评论