Skip to content

Commit b9df7f1

Browse files
committed
update ssr custom directive usage
1 parent a3486df commit b9df7f1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/guide/scaling-up/ssr.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,17 @@ Since most custom directives involve direct DOM manipulation, they are ignored d
309309

310310
```js
311311
const myDirective = {
312-
mounted(el) {
313-
el.id = 'foo'
312+
mounted(el, binding) {
313+
// client-side implementation:
314+
// directly update the DOM
315+
el.id = binding.value
314316
},
315-
getSSRProps(binding, vnode) {
316-
// the hook is passed the directive binding and the element vnode.
317-
// return props to be added to the vnode.
317+
getSSRProps(binding) {
318+
// server-side implementation:
319+
// return the props to be rendered.
320+
// getSSRProps only receives the directive binding.
318321
return {
319-
id: 'foo'
322+
id: binding.value
320323
}
321324
}
322325
}

0 commit comments

Comments
 (0)