1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import Vue from 'vue'
- Vue.mixin({
- components: {
- },
-
-
- data() {
- return {
- $__loading:{
- close(){
-
- }
- },
- loadOption:{
- lock: true,
- text: '上傳中',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- }
- }
- },
- methods: {
- $beforeUpload(file) {
- let type = this.isImage(file.name);
- if (!type) {
- this.$message.error("只允許上傳圖片");
- return type;
- }
- const isLt2M = file.size / 1024 / 1024 < 5;
-
- if (!isLt2M) {
- this.$message.error("上傳圖片大小不能超過 5MB!");
- return isLt2M;
- }
- this.showLoading()
- },
- handleError(){
- this.$alert("上傳失敗,請稍後再試", "提示", {
- confirmButtonText: "確定",
- callback: () => {
- this.$__loading.close()
- },
- });
- },
- showLoading(){
- this.$__loading = this.$loading(this.loadOption)
- },
- $inputnum(e){
- console.log('e',e)
-
- e = (e.match(/^\d*(\.?\d{0,2})/g)[0]) || null
- }
- }
- })
|