X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/afed379c5c2b0ef1fb2e95b1b807b65cd7ece1ef..refs/pull/2169/head:/dev/docs/components.md?ds=inline diff --git a/dev/docs/components.md b/dev/docs/components.md index 2f59ae344..ac0e929cd 100644 --- a/dev/docs/components.md +++ b/dev/docs/components.md @@ -1,16 +1,22 @@ # JavaScript Components -This document details the format for JavaScript components in BookStack. +This document details the format for JavaScript components in BookStack. This is a really simple class-based setup with a few helpers provided. #### Defining a Component in JS ```js class Dropdown { setup() { + this.toggle = this.$refs.toggle; + this.menu = this.$refs.menu; + + this.speed = parseInt(this.$opts.speed); } } ``` +All usage of $refs, $manyRefs and $opts should be done at the top of the `setup` function so any requirements can be easily seen. + #### Using a Component in HTML A component is used like so: