是错误还是我的错? 来自string和localStorage的变量表现不同。
var colors ="", colors2 ="", getColor = "";
var defaultColorScheme = '{"asideBackgroud":"#fff", "asideColor":"#000", "sectionBackgroud":"#eee", "sectionColor":"#111"}';
if (!localStorage.colorScheme) {
localStorage.setItem('colorScheme', JSON.stringify(defaultColorScheme));
}
getColor = localStorage.getItem('colorScheme');
colors = JSON.parse(getColor); // from loc. storage
colors2 = JSON.parse(defaultColorScheme); // string
alert (colors.asideBackgroud+" -- "+ colors2.asideBackgroud);
if (defaultColorScheme === colors) {
alert("yes");
}
//localStorage.clear();