1.a標籤實現前端下載的谷歌兼容
咱們都知道,文件下載的一種實現方案就是後端返回文件流,而後前端進行生成a標籤並觸發點擊來下載。可是在火狐瀏覽器的時候,須要注意一些兼容性問題。緣由是火狐的同源策略。官方說明:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributescss
代碼以下:前端
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是一種思路。vue
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'
}}vuex