收集、管理和分享有用的代码片段,提高开发效率
调用REST API
🔥
启动类配置
package com.example;
import org.springframework.boot.*;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("com.example")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
自定义元素
class CustomButton extends HTMLButtonElement {
constructor() {
super();
this.innerText = 'Click Me';
this.style.backgroundColor = 'blue';
this.style.color = 'white';
this.addEventListener('click', () => {
alert('Button clicked!');
});
}
}
customElements.define('custom-button', CustomButton);
绘制简单图形
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
// Draw rectangle
ctx.fillStyle = '#FF0000';
ctx.fillRect(10, 10, 150, 80);
// Draw circle
ctx.beginPath();
ctx.arc(250, 100, 50, 0, 2 * Math.PI);
ctx.fillStyle = '#0000FF';
ctx.fill();
// Draw text
ctx.font = '30px Arial';
ctx.fillStyle = '#000000';
ctx.fillText('Happy Coding', 150, 200);
简单API端点
🔥
多线程计算
// main.js
const worker = new Worker('worker.js');
worker.onmessage = (e) => {
console.log('Result:', e.data);
};
worker.postMessage(1000000);
// worker.js
self.onmessage = (e) => {
let result = 0;
for(let i = 0; i < e.data; i++) {
result += i;
}
self.postMessage(result);
};
高效管理您的代码片段,提高开发效率
通过关键字、语言或分类快速查找代码片段,支持模糊搜索和过滤功能
支持多种编程语言的语法高亮,使代码更加清晰易读
随时随地访问您的代码片段库,支持桌面和移动设备
浏览最受欢迎的代码分类