File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1212 font-size :  16px  ;
1313 line-height :  1.5 ;
1414 h3  {
15+  color :  red;
1516 margin :  0 ;
1617 line-height :  0 ;
1718 }
1819 }
20+  button  {
21+  padding :  10px   20px  ;
22+  font-size :  16px  ;
23+  }
1924 </ style > 
2025 </ head > 
2126 < body > 
@@ -93,8 +98,8 @@ <h3>解决方案二:fetch() 与 keepalive: true</h3>
9398 // 使用 sendBeacon 发送数据 
9499 // 该方法会返回 true (成功加入队列) 或 false (数据过大或格式错误) 
95100 const  success  =  navigator . sendBeacon ( 
96-  "http://127.0.0.1:666/api/v1/insert?"  +  params . toString ( ) , 
97-  body 
101+  "http://127.0.0.1:666/api/v1/insert?"  +  params . toString ( ) 
102+  //  body // 传递数据 
98103 ) ; 
99104
100105 if  ( success )  { 
@@ -151,7 +156,7 @@ <h3>解决方案二:fetch() 与 keepalive: true</h3>
151156 // 在这种情况下,我们通常不发送信标 
152157 return ; 
153158 } 
154-  //  fetchSendData();
159+  fetchSendData ( ) ; 
155160 } ) ; 
156161
157162 document . querySelector ( "#fetch-btn" ) . onclick  =  function  ( )  { 
                         You can’t perform that action at this time. 
           
                  
0 commit comments