88
99带标签的模版形式如:
1010
11- ``` js
11+ ``` javascript
1212 ` 我需要做:
1313 ${ todos}
1414 当前进度为:${ progress}
1717
1818带标签的模板字面量是一个函数调用的语法糖,上文语法表示实际如下:
1919
20- ``` js
20+ ``` javascript
2121 fn` 我需要做:
2222 ${ todos}
2323 当前进度为:${ progress}
5252 * ` valuel ` 即迭代产生的值
5353* 可使用生成器函数快速创建一个可迭代对象。如:
5454
55- ``` js
55+ ``` javascript
5656 // example1 生成器函数直接生成可迭代对象
5757 function * generator (i ) {
5858 yield i;
129129
130130JS异步函数会立刻返回一个 ` promise ` ,` promise ` 拥有一个状态。可以对返回的 ` promise ` 对象调用 ` then() ` 方法,` then() ` 方法接收一个函数,` promise ` 会用使用** 原异步函数调用` resolve ` 函数的参数** 作为参数调用这个函数。如* Example 1* :
131131
132- ``` js
132+ ``` javascript
133133// Example 1
134134// 使用Promise构造函数创建一个promise对象
135135// resolve函数的参数"done"将在fulfillment时返回,并作为调用then方法的参数
@@ -141,7 +141,7 @@ promise.then((result) => {
141141
142142使用 ` asycn ` 关键字注释的函数可以在函数内部使用 ` await ` 关键字调用异步函数,使异步函数直接返回 ` fulfillment ` ,而不是先返回 ` promise ` 对象。` asycn\await ` 写法也更直观,看起来和同步函数一样。如* Example 2* :
143143
144- ``` js
144+ ``` javascript
145145// Example 2
146146function alarm (person , delay ) {
147147 return new Promise ((resolve , reject ) => {
@@ -177,7 +177,7 @@ button.addEventListener("click", async () => {//使用async关键字
1771772 . 请求成功时存储数据库对象 ` db = openRequest.result; `
1781783 . 创建数据库表,新建自增列:
179179
180- ``` JS
180+ ``` javascript
181181 const objectStore = db .createObjectStore (" notes_os" , {// 创建一个新表命名为notes_os
182182 keyPath: " id" ,// 创建自增列
183183 autoIncrement: true ,
@@ -186,7 +186,7 @@ button.addEventListener("click", async () => {//使用async关键字
186186
1871874 . 创建新的列字段,创建了 ` title ` 和 ` body ` 字段(列)。
188188
189- ``` js
189+ ``` javascript
190190 objectStore .createIndex (" title" , " title" , { unique: false });
191191 objectStore .createIndex (" body" , " body" , { unique: false });
192192 ```
@@ -209,7 +209,7 @@ button.addEventListener("click", async () => {//使用async关键字
209209
210210Proxy用于拦截一些操作,替换成自定义实现。如:
211211
212- ``` js
212+ ``` javascript
213213const handler = {
214214 get (target , property ){
215215 return name in target ? target[name] : 42 ;
@@ -226,7 +226,7 @@ proxy操作不是随意的,需要保持`不可拓展对象`和`不可配置属
226226
227227对象的原型为其` [[Propotype]] ` 属性,由构造器对象的` prototype ` 属性定义。即:
228228
229- ``` js
229+ ``` javascript
230230let s = new String (' a' );
231231Object .getPrototypeOf (s) === String .prototype ;
232232```
@@ -243,7 +243,7 @@ Object.getPrototypeOf(s) === String.prototype;
243243
244244#### 组合选择器
245245
246- ``` CSS
246+ ``` css
247247.a {
248248 .b {} /* 相当于 .a .b 即属于class="a"的子元素,且自身class="b"的元素 */
249249 &.b {} /* 相当于 .a.b 即class="a b"或"b a" */
@@ -256,7 +256,7 @@ Object.getPrototypeOf(s) === String.prototype;
256256
257257#### 后附嵌套选择器
258258
259- ``` CSS
259+ ``` css
260260.a {
261261 .b & {} /* 相当于 .b.a 即class="a b"或"b a" */
262262 .b & {} /* 相当于 .b .a 即属于class="b"的子元素,且自身class="a"的元素 */
@@ -268,7 +268,7 @@ Object.getPrototypeOf(s) === String.prototype;
268268
269269### 优先级
270270
271- 一条CSS声明的优先级分三层判断
271+ 一条css声明的优先级分三层判断
272272
273273* 来源,用户代理、用户样式、作者样式优先级从低到高按如下排序。
274274 1 . 用户代理普通样式
@@ -588,7 +588,7 @@ sveltekit完成一次任务需要经过如下三步
5885881 . 安装静态设配器 ` npm i -D @sveltejs/adapter-static `
5895892 . 配置根目录的svelte.config.js文件:
590590
591- ``` js
591+ ``` javascript
592592 import adapter from ' @sveltejs/adapter-static' ;
593593
594594 /** @type {import('@sveltejs/kit').Config} */
@@ -617,7 +617,7 @@ sveltekit完成一次任务需要经过如下三步
617617
6186183 . 配置src文件夹下的+layout.js文件
619619
620- ``` js
620+ ``` javascript
621621 export const prerender = true ;
622622 ```
623623
@@ -699,7 +699,7 @@ sveltekit完成一次任务需要经过如下三步
699699
700700函数如下,函数接受` event ` 对象,` resolve ` 函数。返回一个` Response ` 。
701701
702- ``` js
702+ ``` javascript
703703 export async function handle ({ event , resolve }) {
704704 return await resolve (event );
705705 }
0 commit comments