/
githubmirror
/
d3
Обзор
Документация
Войти
/
githubmirror
/
d3
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/components/ColorSwatches.vue
29 строк
511 B
Mike Bostock
vitepress docs (#3654)
08 июн 2023, 04:30
Не верифицирован
08 июн 2023, 04:30
6d6c679
Код
Авторство
О чём код?
<script> function render(canvas, colors) { const n = colors.length; const r = 40; canvas.width = n * r; canvas.height = r; const context = canvas.getContext("2d"); for (let i = 0; i < n; ++i) { context.fillStyle = colors[i]; context.fillRect(i * r, 0, r, r); } } export default { props: ["colors"], mounted() { render(this.$el, this.colors); }, updated() { render(this.$el, this.colors); } } </script> <template> <canvas style="height: 40px;"></canvas> </template>