diff --git "a/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/index.html" "b/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/index.html" new file mode 100644 index 0000000..84b67af --- /dev/null +++ "b/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/index.html" @@ -0,0 +1,28 @@ + + + +
+ + + +hello
++ 选择样式: + + +
+ + + + \ No newline at end of file diff --git "a/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/style.css" "b/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/style.css" new file mode 100644 index 0000000..74163a2 --- /dev/null +++ "b/01-\346\217\220\345\211\215\345\274\225\345\205\245\346\211\200\346\234\211\344\270\273\351\242\230\346\240\267\345\274\217\357\274\214\345\201\232\347\261\273\345\220\215\345\210\207\346\215\242/style.css" @@ -0,0 +1,16 @@ +/* day样式主题 */ +body.day .box { + color: #f90; + background: #fff; +} +/* dark样式主题 */ +body.dark .box { + color: #eee; + background: #333; +} + +.box { + width: 100px; + height: 100px; + border: 1px solid #000; +} diff --git "a/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/index.html" "b/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/index.html" new file mode 100644 index 0000000..c4ed82e --- /dev/null +++ "b/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/index.html" @@ -0,0 +1,29 @@ + + + + + + + +hello
++ 选择样式: + + + +
+ + + + \ No newline at end of file diff --git "a/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/style.css" "b/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/style.css" new file mode 100644 index 0000000..eaf2e40 --- /dev/null +++ "b/02-CSS\345\217\230\351\207\217+\347\261\273\345\220\215\345\210\207\346\215\242/style.css" @@ -0,0 +1,29 @@ +/* 定义根作用域下的变量 */ +:root { + --theme-color: #333; + --theme-background: #eee; +} +/* 更改dark类名下变量的取值 */ +.dark{ + --theme-color: #eee; + --theme-background: #333; +} +/* 更改pink类名下变量的取值 */ +.pink{ + --theme-color: #fff; + --theme-background: pink; +} + +.box { + transition: all .2s; + width: 100px; + height: 100px; + border: 1px solid #000; + /* 使用变量 */ + color: var(--theme-color); + background: var(--theme-background); +} + +html.dark { + color-scheme: dark; +} \ No newline at end of file diff --git "a/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/01-\347\256\200\345\215\225\347\224\250\346\263\225.html" "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/01-\347\256\200\345\215\225\347\224\250\346\263\225.html" new file mode 100644 index 0000000..d43ecd2 --- /dev/null +++ "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/01-\347\256\200\345\215\225\347\224\250\346\263\225.html" @@ -0,0 +1,20 @@ + + + +hello
+ + + \ No newline at end of file diff --git "a/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/01.js" "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/01.js" new file mode 100644 index 0000000..03fe083 --- /dev/null +++ "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/01.js" @@ -0,0 +1,40 @@ +// 定义暗黑主题变量 +export default { + fontSize: '16px', + fontColor: '#eee', + background: '#333', +}; +// 定义白天主题变量 +export default { + fontSize: '20px', + fontColor: '#f90', + background: '#eee', +}; + +import { shallowRef } from 'vue'; +// 引入主题 +import theme_day from './theme_day'; +import theme_dark from './theme_dark'; + +// 定义在全局的样式变量 +const theme = shallowRef({}); + +export function useTheme() { + // 尝试从本地读取 + const localTheme = localStorage.getItem('theme'); + theme.value = localTheme ? JSON.parse(localTheme) : theme_day; + + const setDayTheme = () => { + theme.value = theme_day; + }; + + const setDarkTheme = () => { + theme.value = theme_dark; + }; + + return { + theme, + setDayTheme, + setDarkTheme, + }; +} \ No newline at end of file diff --git "a/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/02-themehook.html" "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/02-themehook.html" new file mode 100644 index 0000000..2d73e2b --- /dev/null +++ "b/03-Vue3\346\226\260\347\211\271\346\200\247\357\274\210v-bind\357\274\211/\345\256\236\347\216\260/02-themehook.html" @@ -0,0 +1,49 @@ + + + +