Преглед на файлове

Image: Fix image ssr (#16737) (#16747)

* fix ssr

* refine
luckyCao преди 6 години
родител
ревизия
2364c022ab
променени са 2 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 2 3
      packages/image/src/image-viewer.vue
  2. 4 0
      src/utils/util.js

+ 2 - 3
packages/image/src/image-viewer.vue

@@ -53,7 +53,7 @@
 
 <script>
 import { on, off } from 'element-ui/src/utils/dom';
-import { rafThrottle } from 'element-ui/src/utils/util';
+import { rafThrottle, isFirefox } from 'element-ui/src/utils/util';
 
 const Mode = {
   CONTAIN: {
@@ -66,8 +66,7 @@ const Mode = {
   }
 };
 
-const isFirefox = !!window.navigator.userAgent.match(/firefox/i);
-const mousewheelEventName = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
+const mousewheelEventName = isFirefox() ? 'DOMMouseScroll' : 'mousewheel';
 
 export default {
   name: 'elImageViewer',

+ 4 - 0
src/utils/util.js

@@ -122,6 +122,10 @@ export const isEdge = function() {
   return !Vue.prototype.$isServer && navigator.userAgent.indexOf('Edge') > -1;
 };
 
+export const isFirefox = function() {
+  return !Vue.prototype.$isServer && !!window.navigator.userAgent.match(/firefox/i);
+};
+
 export const autoprefixer = function(style) {
   if (typeof style !== 'object') return style;
   const rules = ['transform', 'transition', 'animation'];