# P5.js Code Challenge
Youtube - The Coding Train - Coding Challenge (opens new window)
# 模板代码
<template>
<div id="p5-container" ref="p5"></div>
</template>
<script>
import p5 from "p5"
export default {
mounted() {
const containerEl = this.$refs.p5;
const width = containerEl.clientWidth;
const height = containerEl.clientHeight;
const sketch = function (p) {
p.setup = function () {
p.createCanvas(width, height);
//
};
p.draw = function () {
p.background(230, 230, 250);
// ...
};
};
new p5(sketch, containerEl);
},
};
</script>