@@ -10,8 +10,8 @@ const EL = {
10
10
name : 'el' ,
11
11
type : 'string | HTMLElement' ,
12
12
restriction : `only respected in instance created via ${ colorArgs ( 'new' ) } .` ,
13
- details : `Provide the Vue instance an existing DOM element to mount on. It can be a CSS selector string or
14
- an actual HTMLElement. After the instance is mounted,
13
+ details : `Provide the Vue instance an existing DOM element to mount on. It can be a CSS
14
+ selector string or an actual HTMLElement. After the instance is mounted,
15
15
the resolved element will be accessible as ${ colorArgs ( 'vm.$el' ) } .
16
16
If this option is available at instantiation, the instance will immediately enter
17
17
compilation; otherwise, the user will have to explicitly call ${ colorArgs ( 'vm.$mount()' ) } to manually
@@ -20,12 +20,61 @@ const EL = {
20
20
mounted element will be replaced with Vue-generated DOM in all cases. It is therefore
21
21
not recommended to mount the root instance to ${ colorArgs ( '<html>' ) } or ${ colorArgs ( '<body>' ) } .
22
22
If neither ${ colorArgs ( 'render' ) } function nor ${ colorArgs ( 'template' ) } option is present, the in-DOM HTML of
23
- the mounting DOM element will be extracted as the template. In this case, Runtime + Compiler build of Vue should be used.`
23
+ the mounting DOM element will be extracted as the template. In this case,
24
+ Runtime + Compiler build of Vue should be used.`
24
25
,
25
26
}
26
- const TEMPLATE = { }
27
- const RENDER = { }
28
- const RENDER_ERROR = { }
27
+ // untested
28
+ const TEMPLATE = {
29
+ category : 'Options/DOM' ,
30
+ name : 'template' ,
31
+ type : 'string' ,
32
+ details : `A string template to be used as the markup for the Vue instance.
33
+ The template will replace the mounted element. Any existing markup inside the mounted
34
+ element will be ignored, unless content distribution slots are present in the template.
35
+ If the string starts with ${ colorArgs ( '#' ) } it will be used as a querySelector and use the selected element’s
36
+ innerHTML as the template string. This allows the use of the common ${ colorArgs ( `<script type="x-template">` ) }
37
+ trick to include templates. From a security perspective, you should only use Vue templates
38
+ that you can trust. Never use user-generated content as your template.
39
+ If render function is present in the Vue option, the template will be ignored.
40
+
41
+ `
42
+ }
43
+ const RENDER = {
44
+ category : 'Options/DOM' ,
45
+ name : 'render' ,
46
+ type : '(createElement: () => VNode) => VNode' ,
47
+ details : `An alternative to string templates allowing you to leverage the full programmatic
48
+ power of JavaScript. The render function receives a ${ colorArgs ( 'createElement' ) } method
49
+ as it’s first argument used to create ${ colorArgs ( 'VNode' ) } s. If the component is a functional component,
50
+ the render function also receives an extra argument ${ colorArgs ( 'context' ) } , which provides access to
51
+ contextual data since functional components are instance-less.
52
+
53
+ The ${ colorArgs ( 'render' ) } function has priority over the render function compiled from ${ colorArgs ( 'template' ) } option
54
+ or in-DOM HTML template of the mounting element which is specified by the ${ colorArgs ( 'el' ) } option.
55
+
56
+ `
57
+ }
58
+ const RENDER_ERROR = {
59
+ category : 'Options/DOM' ,
60
+ name : 'renderError' ,
61
+ type : '(createElement: () => VNode, error: Error) => VNode' ,
62
+ details : `${ chalk . bold ( 'Only works in development mode' ) } .
63
+ Provide an alternative render output when the default ${ colorArgs ( 'render' ) } function encounters
64
+ an error. The error will be passed to ${ colorArgs ( 'renderError' ) } as the second argument.
65
+ This is particularly useful when used together with hot-reload` ,
66
+ example : `
67
+ ${ colorArgs ( 'new' ) } Vue({
68
+ render (h) {
69
+ ${ colorArgs ( 'throw new' ) } ${ chalk . green ( 'Error' ) } (${ chalk . green ( "'oops'" ) } )
70
+ },
71
+ renderError (h, err) {
72
+ ${ colorArgs ( 'return' ) } h(${ chalk . green ( "'pre'" ) } , { style: { color: ${ chalk . green ( "'red'" ) } }}, err.stack)
73
+ }
74
+ }).$mount(${ chalk . green ( "'#app'" ) } )
75
+
76
+ `
77
+ }
29
78
30
79
31
80
module . exports = {
0 commit comments