在ios10.2中的safri浏览器里无痕模式会导致localstorage不能正常使用
具体解决办法如下:
if (typeof localStorage === 'object') { try { localStorage.setItem('localStorage', 1); localStorage.removeItem('localStorage'); } catch (e) { Storage.prototype._setItem = Storage.prototype.setItem; Storage.prototype.setItem = function() {}; alert('Your web browser does not support storing settings locally. In Safari, the most common cause of this is using "Private Browsing Mode". Some settings may not save or some features may not work properly for you.'); } }
后来点击右下角小框框发现有个无痕浏览的模式。MD,关闭后一切正常