You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/start/spec.md
+64-1Lines changed: 64 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,10 +70,66 @@ More details can be found in [Using Pre-Processors](../configurations/pre-proces
70
70
71
71
- By default, contents will be extracted and dynamically inserted into the document's `<head>` as an actual `<style>` tag using `style-loader`. It's also possible to [configure Webpack so that all styles in all components are extracted into a single CSS file](../configurations/extract-css.md).
72
72
73
-
### Custom Language Blocks
73
+
### Custom Blocks
74
74
75
75
Additional custom blocks can be included in a `*.vue` file for any project specific needs. `vue-loader` will use the tag name to look up which webpack loaders should be applied to the contents of the section. The webpack loaders should be specified in the `loaders` hash of the `vue` section of the webpack configuration in the same way that languages are specified for the standard sections of the file. See [Advanced Loader Configuration](../configurations/advanced.md).
76
76
77
+
Example:
78
+
79
+
#### component.vue
80
+
```html
81
+
<unit-test>
82
+
describe('example', function () {
83
+
it('basic', function (done) {
84
+
done();
85
+
})
86
+
})
87
+
</unit-test>
88
+
89
+
<template>
90
+
<h2class="red">{{msg}}</h2>
91
+
</template>
92
+
93
+
<script>
94
+
exportdefault {
95
+
data () {
96
+
return {
97
+
msg:'Hello from Component A!'
98
+
}
99
+
}
100
+
}
101
+
</script>
102
+
103
+
<style>
104
+
comp-ah2 {
105
+
color: #f00;
106
+
}
107
+
</style>
108
+
```
109
+
110
+
#### webpack.config.js
111
+
112
+
```js
113
+
// Webpack 2.x (^2.1.0-beta.25)
114
+
module.exports= {
115
+
module: {
116
+
rules: [
117
+
{
118
+
test:/\.vue$/,
119
+
loader:'vue',
120
+
// vue-loader options go here
121
+
options: {
122
+
loaders: {
123
+
unit-test:'buble-loader',
124
+
}
125
+
}
126
+
}
127
+
]
128
+
}
129
+
}
130
+
```
131
+
132
+
77
133
### Src Imports
78
134
79
135
If you prefer splitting up your `*.vue` components into multiple files, you can use the `src` attribute to import an external file for a language block:
@@ -91,6 +147,13 @@ Beware that `src` imports follow the same path resolution rules to CommonJS `req
91
147
<stylesrc="todomvc-app-css/index.css">
92
148
```
93
149
150
+
`src` imports also work with custom blocks, e.g.:
151
+
152
+
``` html
153
+
<unit-test src="./unit-test.js">
154
+
</unit-test>
155
+
```
156
+
94
157
### Syntax Highlighting
95
158
96
159
Currently there is syntax highlighting support for [Sublime Text](https://github.com/vuejs/vue-syntax-highlight), [Atom](https://atom.io/packages/language-vue), [Vim](https://github.com/posva/vim-vue), [Visual Studio Code](https://marketplace.visualstudio.com/items/liuji-jim.vue), [Brackets](https://github.com/pandao/brackets-vue), and [JetBrains products](https://plugins.jetbrains.com/plugin/8057) (WebStorm, PhpStorm, etc). Contributions for other editors/IDEs are highly appreciated! If you are not using any pre-processors in Vue components, you can also get by by treating `*.vue` files as HTML in your editor.
0 commit comments