a标签前端下载火狐兼容和笔记

1.a标签实现前端下载的谷歌兼容

  我们都知道,文件下载的一种实现方案就是后端返回文件流,然后前端进行生成a标签并触发点击来下载。但是在火狐浏览器的时候,需要注意一些兼容性问题。原因是火狐的同源策略。官方说明:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes

  代码如下:

 1 download(row) {
 2       downloadFile({ id: row.fileId }).then(res => {
 3         // window.open(URL.createObjectURL(res.data))
 4         const blob = new Blob([res.data], { type: row.fileType })
 5         // var a = document.createElement('a')兼容火狐
 6         const a = document.getElementById('downFA')
 7         a.href = URL.createObjectURL(blob)
 8         a.download = row.fileName
 9         a.click()
10         // URL.revokeObjectUrl(a.href)
11       })
12     }

2.vue的mixin

3.vue的cropper图片裁剪插件

4.css的/deep/

5.vuex中的数据何时才能获取到

由于是异步的,mouted时有时会获取不到?改成created也会有时获取不到?使用watch是一种思路。

6.vue中响应式的对象变更检测tip

vue是响应式的,但是由于 JavaScript 的限制,Vue 不能检测对象属性的添加或删除,比如:
定义了data:form:{}对于form中的属性可以动态刷新,但是当给form新增了别的属性之后,则新增的属性的module和view不能双向响应刷新。此时需要使用set或 Object.assign来进行新增绑定属性。
((Object.assign() 或 _.extend()????))
set:一个,assign:可多个
Vue.set(vm.userProfile, 'age', 27)
vm.$set(vm.userProfile, 'age', 27)
vm.userProfile = Object.assign({}, vm.userProfile, {
age: 27,
favoriteColor: 'Vue Green'
})
eg:this.$set(this.form, 'holder', res.data)
eg:this.form = Object.assign({}, this.form, {
age: 27,
favoriteColor: 'Vue Green'
}}

posted @ 2019-08-29 11:16  TheFirstDream  阅读(1207)  评论(0)    收藏  举报