Skip to content

Commit

Permalink
fix: mounted wechat bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hua1995116 committed May 6, 2019
1 parent 577f530 commit 8987ce1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import 'muse-ui/dist/muse-ui.css';
import './styles/main.styl';
import socket from './socket';
import {queryString} from '@utils/queryString';
import ios from './utils/ios';

// 微信 回弹 bug
ios();

import vuePicturePreview from './components/photo-viewer';
Vue.use(vuePicturePreview);
Expand Down
15 changes: 6 additions & 9 deletions src/utils/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ export default function () {
const u = navigator.userAgent;
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
const classList = 'input';
setTimeout(() => {
[].forEach.call(document.querySelectorAll(classList), function(el) {
el.addEventListener("blur", function(e) {
console.log(1111);
if (isIOS) {
blurAdjust();
}
});
[].forEach.call(document.querySelectorAll(classList), function(el) {
el.addEventListener("blur", function(e) {
if (isIOS) {
blurAdjust();
}
});
}, 1000);
});

// 解决苹果不回弹页面 https://blog.csdn.net/m0_37520980/article/details/86305488
function blurAdjust(e) {
Expand Down
5 changes: 4 additions & 1 deletion src/view/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
import Alert from '@components/Alert';
import debounce from 'lodash/debounce';
import url from '@api/server';
import { setTimeout } from 'timers';
import { setTimeout } from 'timers';
import ios from '@utils/ios';
export default{
data() {
Expand Down Expand Up @@ -157,6 +158,8 @@ import { setTimeout } from 'timers';
this.noticeVersion = res.data.version;
},
async mounted() {
// 微信 回弹 bug
ios();
this.container = document.querySelector('.chat-inner');
// socket内部,this指针指向问题
const that = this;
Expand Down
3 changes: 3 additions & 0 deletions src/view/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import SvgModal from "@components/svg-modal";
import Alert from "@components/Alert";
import Toast from "@components/Toast";
import socket from "../socket";
import ios from '@utils/ios';
// import Loading from '../components/loading/loading'
export default {
Expand Down Expand Up @@ -73,6 +74,8 @@ export default {
}
},
mounted() {
// 微信 回弹 bug
ios();
this.$store.commit("setTab", false);
if (!this.getSvgModal) {
const svg = SvgModal();
Expand Down
3 changes: 3 additions & 0 deletions src/view/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import SvgModal from "@components/svg-modal";
import Alert from "@components/Alert";
import Toast from "@components/Toast";
import socket from "../socket";
import ios from '@utils/ios';
export default {
methods: {
Expand Down Expand Up @@ -73,6 +74,8 @@ export default {
}
},
mounted() {
// 微信 回弹 bug
ios();
this.$store.commit("setTab", false);
if (!this.svgmodal) {
const svg = SvgModal();
Expand Down

0 comments on commit 8987ce1

Please sign in to comment.