Skip to content

Commit a01af8f

Browse files
committed
Merge branch 'master' of github.com:shawwwn/vueify.js
2 parents 56a1346 + 02c8f83 commit a01af8f

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Vueify.js
22

3-
Browser loading .vue file from script tag. No muss, no fuss!
3+
A Vue plugin that enables browser loading .vue files from either script tags or dynamic imports.
44

55
<img src="https://user-images.githubusercontent.com/4016736/55936265-a29a3200-5bea-11e9-90a7-46bbd762c0c2.png" width="200" height="230" />
66

77
## Description:
8-
___Tl;dr.___ `Vueify.js` is an attempt to recreate the desired behavior of [Vueify](https://github.com/vuejs/vueify) in browser environment!
8+
___Tl;dr.___ `Vueify.js` is an attempt to recreate the desired behavior of [Vueify](https://github.com/vuejs/vueify) in browser environment hence suffix with .js to indicate it is a frontend library.
99

1010
> Vue's [Single-File-Compoment(SFC)](https://vuejs.org/v2/guide/single-file-components.html) is a nice feature allowing modular code and easier code refactorization. However, a SFC **(*.vue)** file needs to be locally compiled into into browser recognizable primitives(js, css, etc.) before shipping to your browser. This process is not at all straight-forward. At the minimium you will need:
1111
>
@@ -17,21 +17,41 @@ ___Tl;dr.___ `Vueify.js` is an attempt to recreate the desired behavior of [Vuei
1717
1818

1919
## Usage:
20-
**First include script tags linked to .vue files, then include vueify.js**
2120

22-
Set `type='vue'` for our script tags, because browser won't automatically load content in script tags with unknown type.
23-
21+
**Include vueify.js to your html, then initialize the plugin with `Vue.use()`.**
22+
2423
```html
25-
<script src="Hello.vue" type='vue'></script>
2624
<script src="vueify.js"></script>
2725
```
2826

29-
SFC loaded this way will be registered globally under the its file name (e.g., Hello.vue ==> hello) or the name user specified in script tag.
30-
31-
```html
27+
```js
28+
Vue.use(Vueify);
29+
var app = new Vue({ ... });
30+
```
31+
32+
**Static Loading .vue file via \<script\> and register it as a global component**
33+
34+
*Set `type='vue'` for our script tags, because browser won't automatically load content in script tags with unknown type.*
35+
36+
```html
37+
<script src="Hello.vue" type='vue'></script> // component name with be default to 'hello'
3238
<script src="Hello.vue" type='vue' name='custom-name'></script>
3339
```
3440

41+
**Dynamic Loading .vue file**
42+
43+
*Just like `import()` but works with \*.vue*
44+
45+
```js
46+
var component1_option = await Vue.importSFC('./component1.vue');
47+
var app = new Vue({
48+
components: {
49+
component1: component1_option,
50+
component2: () => Vue.importSFC('./component2.vue'),
51+
},
52+
}
53+
```
54+
3555
3656
## How It Works:
3757
`vueify.js` will first scan document for script tags with `type=vue`, gather url for .vue files.
@@ -41,7 +61,7 @@ It then downloads and transpiles these .vue files and their dependent .vue files
4161
We refer to .vue files inside script tags as root-level therefore they will be automatically loaded as global Vue components by `vueify.js`. Users are responsible for registering any children Vue component inside these .vue files.
4262
4363
44-
## Example:
64+
## Minimum Example:
4565
Write your Vue component like this:
4666
```html
4767
// Hello.vue
@@ -89,7 +109,6 @@ Then write your html like this:
89109
90110
91111
## Note:
92-
* Please verify that `vueify.js` loads after `vue.js` and `*.vue`.
93112
* No custom lang support ~~lang="coffee"~~ in .vue.
94113
* Use ES6's `import/export` for nested components, CommonJS's `require/module.exports` is not currently supported.
95114
* Cyclic dependency in .vue file will cause transpile error.

0 commit comments

Comments
 (0)