18-12-17

212 阅读1分钟

canvas使用toDataURL()时报错的问题

error:Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. 这是由同源策略引起的错误,canvas上的用到的图片来没有添加跨域属性

//注意,这里新建的image标签还没有赋src属性值
let image= new Image();
image.setAttribute("crossOrigin",'Anonymous');

横向滚动元素,父元素无法被撑开的解决

给没有被撑开的父元素添加

width: fit-content;

样式

以管理员身份运行cmd

vue中,当根元素有v-if或v-show时,mounted中可能取不到$el

这种现象常出现在使用先骨架再vuex异步填充数据的框架中,可以把原本需要执行的逻辑放入updated中

经纬度

  1. 经度:lng 取值 0~180
  2. 纬度:lat 取值 0~90

ios和火狐下无法取得event.path的垫片

handler(e){
  //e.composedPath为ios和火狐下下的方法
  let path= e.path || e.composedPath();
}

前端埋点统计方法

juejin.cn/post/684490…

slots声明方法

//通过this.$slots.sdf取得
<template slot="sdf">
  <div>
    <img src="http://qiniu.17lvju.com/images/888025784367775755.jpg" alt="">
  </div>
</template>
//通过this.$slots.find(ele => { return ele.key=== 'sdf'})
<slot>
    <div key="sdf">...</div>
</slot>

slots使用方法

//父组件中
<xxx-comp>
    <slot>
    ...
    </slot>
    <template slot="test">
    ...
    </template>
    <slot>
    ...
    </slot>
</xxx-comp>
//xxx-comp中
<div class="fixed-title">
    //所有未命名的插槽都会放在这里
    <slot></slot>
    <div class="test">
      //命名插槽
      <slot name="test"></slot>
    </div>
</div>