Skip to content

Commit 9d6c4d8

Browse files
author
Guillaume Chau
committed
docs(ui): more code examples
1 parent 9853471 commit 9d6c4d8

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/plugin-dev-ui.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ api.describeTask({
261261
}
262262
],
263263
// Default selected view when displaying the task details (by default it's the output)
264-
defaultView: 'vue-webpack-dashboard'
264+
defaultView: 'vue-webpack-dashboard-client-addon'
265265
})
266266
```
267267

@@ -388,10 +388,21 @@ api.describeTask({
388388
}
389389
],
390390
// Default selected view when displaying the task details (by default it's the output)
391-
defaultView: 'vue-webpack-dashboard'
391+
defaultView: 'vue-webpack-dashboard-client-addon'
392392
})
393393
```
394394

395+
Here is the client addon code that register the `'vue-webpack-dashboard'` component (like we saw earlier):
396+
397+
```js
398+
/* In `main.js` */
399+
// Import the component
400+
import WebpackDashboard from './components/WebpackDashboard.vue'
401+
// Register a custom component
402+
// (works like 'Vue.component')
403+
ClientAddonApi.component('vue-webpack-dashboard', WebpackDashboard)
404+
```
405+
395406
![Task view example](./task-view.png)
396407

397408
### Custom views
@@ -417,6 +428,21 @@ api.addView({
417428
})
418429
```
419430

431+
Here is the code in the client addon that register the `'test-webpack-route'` (like we saw earlier):
432+
433+
```js
434+
/* In `main.js` */
435+
// Import the component
436+
import TestView from './components/TestView.vue'
437+
// Add routes to vue-router under a /addon/<id> parent route.
438+
// For example, addRoutes('foo', [ { path: '' }, { path: 'bar' } ])
439+
// will add the /addon/foo/ and the /addon/foo/bar routes to vue-router.
440+
// Here we create a new '/addon/vue-webpack/' route with the 'test-webpack-route' name
441+
ClientAddonApi.addRoutes('vue-webpack', [
442+
{ path: '', name: 'test-webpack-route', component: TestView }
443+
])
444+
```
445+
420446
![Custom view example](./custom-view.png)
421447

422448
### Shared data

0 commit comments

Comments
 (0)