feat: VConsole控制台
This commit is contained in:
parent
cae71c314e
commit
2454920f72
53
html/VConsole调试.html
Normal file
53
html/VConsole调试.html
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>VConsole Example</title>
|
||||||
|
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||||
|
<script>
|
||||||
|
// VConsole 会自动挂载到 `window.VConsole`
|
||||||
|
var vConsole = new window.VConsole();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>VConsole Network Request Example</h1>
|
||||||
|
<button id="fetch-data">Fetch Data</button>
|
||||||
|
<button id="post-data">Post Data</button>
|
||||||
|
<script>
|
||||||
|
document.getElementById('fetch-data').addEventListener('click', function() {
|
||||||
|
// 发起一个网络请求
|
||||||
|
fetch('https://jsonplaceholder.typicode.com/posts/1?name=123')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('Fetched Data:', data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Post request example
|
||||||
|
document.getElementById('post-data').addEventListener('click', function() {
|
||||||
|
fetch('https://jsonplaceholder.typicode.com/posts', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
title: 'foo',
|
||||||
|
body: 'bar',
|
||||||
|
userId: 1
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('Posted Data:', data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user