Browse Source

ie8的onInput代替函数

zhouna 6 years ago
parent
commit
5e7834e1ff

+ 8 - 1
src/common/components/EditableSpan/index.jsx

@@ -1,8 +1,10 @@
 import React,{Component} from 'react';
 import style from './index.less';
 import config from "@config/index";
-import {filterArr,handleEnter} from '@utils/tools.js';
+import {filterArr,handleEnter,isIE} from '@utils/tools.js';
 import Notify from '../Notify/index.js';
+
+import $ from 'jquery';
 /*****
  * author:zn@2018-12-10
  * 自由文本输入组件
@@ -117,6 +119,11 @@ class EditableSpan extends Component{
     if(value){
       this.$span.current.innerText = value||'';
     }
+    if(isIE()){
+      $(this.$span.current).onIe8Input(function(e){
+        this.onChange(e)
+      },this);
+    }
   }
 
   render() {

+ 7 - 0
src/common/components/Textarea/index.jsx

@@ -3,6 +3,8 @@ import style from "./index.less";
 import Notify from '../Notify';
 import config from '@config/index';
 import {setLastPosition} from '@common/js/util';
+import {isIE} from '@utils/tools.js';
+import $ from "jquery";
 
 class Textarea extends Component {
   constructor(props) {
@@ -84,6 +86,11 @@ class Textarea extends Component {
     if(value){
       this.$dom.current.innerText = value||'';
     }
+    if(isIE()){
+      $(this.$span.current).onIe8Input(function(e){
+        this.handleInput(e)
+      },this);
+    }
   }
   render() {
     const { title } = this.props;

+ 13 - 0
src/main.js

@@ -15,6 +15,19 @@ const render = (Component) => {
       = c.clear = c.exception = c.trace = c.assert = function () { };
     return c;
   })();
+  //ie8 onInput替代函数
+  $.fn.onIe8Input = function (fn,thisVal) {
+    return this.each(function () {
+      var $this = $(this);
+      var htmlold = $this.html();
+      $this.bind('blur keyup paste cut mouseup', function (e) {
+        var htmlnew = $this.html();
+        if (htmlold !== htmlnew) {
+          fn.call(thisVal,e);
+        }
+      })
+    })
+  };
     ReactDOM.render(
         <AppContainer>
             <Provider store={store}>

+ 3 - 3
src/utils/ajax.js

@@ -51,7 +51,7 @@ const post=(url,data)=>{
 
   return axios({
     method:'post',
-    url:url,
+    url:host+url,
     data
   });
 };
@@ -62,7 +62,7 @@ const json=(url,data)=>{
   return new Promise((resolve,reject)=>{
     $.ajax({
       method:'post',
-      url:url,
+      url:host+url,
       data:JSON.stringify(data),
       contentType:"application/json; charset=UTF-8",
       success:function(res){
@@ -76,7 +76,7 @@ const json=(url,data)=>{
 };
 
 const get=(url)=>{
-  return axios.get(url).then(data=>data.data);
+  return axios.get(host+url).then(data=>data.data);
 };
 
 module.exports={

+ 1 - 1
src/utils/config.js

@@ -1,5 +1,5 @@
 // const host='http://192.168.3.100:5050';//王峰
-const host='http://192.168.2.241:5050';//后端接口访问地址
+const host='http://192.168.2.236:5050';//后端接口访问地址
 //const host='http://192.168.2.164:8080';
 // const host='http://192.168.3.117:8080'; //周铁刚
 // const newIcssVisitUrl = '223.93.170.82:13000';    //icss服务访问地址(跳转目的地),不能加http://