@dolphinweex/weex-vue-render 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/dist/index.common.js +10770 -0
- package/dist/index.js +10825 -0
- package/dist/index.min.js +1 -0
- package/dist/index.min.js.gz +0 -0
- package/package.json +53 -0
- package/src/index.core.js +21 -0
- package/src/index.js +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# weex-vue-render
|
|
2
|
+
|
|
3
|
+
Web renderer for weex project. Support Vue 2.x syntax.
|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.org/weexteam/weex-vue-render)
|
|
6
|
+
[](https://img.shields.io/badge/vue-2.x-brightgreen.svg)
|
|
7
|
+
[](https://npmjs.com/package/weex-vue-render)
|
|
8
|
+
[](https://npmjs.com/package/weex-vue-render)
|
|
9
|
+
[](http://packagequality.com/#?package=weex-vue-render)
|
|
10
|
+
|
|
11
|
+
## How To Use
|
|
12
|
+
|
|
13
|
+
We strongly suggest you use v1.x instead of 0.12.x, according to performance issue.
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
npm install weex-vue-render
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
// import vue runtime.
|
|
21
|
+
const Vue = require('vue/dist/vue.runtime.common').default
|
|
22
|
+
// import weex-vue-render
|
|
23
|
+
const weex = require('weex-vue-render')
|
|
24
|
+
// init the weex instance.
|
|
25
|
+
weex.init(Vue)
|
|
26
|
+
// import your .vue App.
|
|
27
|
+
const App = require('App.vue')
|
|
28
|
+
// must have a '#root' element in your html body.
|
|
29
|
+
App.$el = '#root'
|
|
30
|
+
// instantiate
|
|
31
|
+
new App()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> The way to require ES modules and CommonJS modules may have a slice of difference between different versions of Vue and Vue-loader, and this is totally depending on Vue and the loader, so please check out related documents.
|
|
35
|
+
|
|
36
|
+
> If your import the UMD formated bundle to the html, then you dont't have to call `init` manually.
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<script>{{Vue runtime}}</script>
|
|
40
|
+
<script>{{weex-vue-render}}</script>
|
|
41
|
+
<script>{{your web.bundle.js}}</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### pack your .vue file to web.bundle.js
|
|
45
|
+
|
|
46
|
+
> You should pack your web.bundle.js and native.bundle.js separately. Use weex-loader for native packing and use vue-loader for web packing.
|
|
47
|
+
|
|
48
|
+
Use [vue-loader](https://github.com/vuejs/vue-loader) to pack your code for web.bundle.js.
|
|
49
|
+
|
|
50
|
+
If you are using weex-vue-render@**1.x** , You should definitely use below plugins to get things work:
|
|
51
|
+
|
|
52
|
+
* weex-vue-precompiler
|
|
53
|
+
* autoprefixer
|
|
54
|
+
* postcss-plugin-weex
|
|
55
|
+
* postcss-plugin-px2rem
|
|
56
|
+
|
|
57
|
+
> We use weex-vue-precompiler instead of `$processStyle` in 1.x verison.
|
|
58
|
+
|
|
59
|
+
Now, how to use this plugins to pack you web.bundle.js ? We use them in the vue-loader option.
|
|
60
|
+
|
|
61
|
+
Here is a vue-loader option example:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
{ // webpack config.
|
|
65
|
+
vue: {
|
|
66
|
+
optimizeSSR: false,
|
|
67
|
+
postcss: [
|
|
68
|
+
// to convert weex exclusive styles.
|
|
69
|
+
require('postcss-plugin-weex')(),
|
|
70
|
+
require('autoprefixer')({
|
|
71
|
+
browsers: ['> 0.1%', 'ios >= 8', 'not ie < 12']
|
|
72
|
+
}),
|
|
73
|
+
require('postcss-plugin-px2rem')({
|
|
74
|
+
// base on 750px standard.
|
|
75
|
+
rootValue: 75,
|
|
76
|
+
// to leave 1px alone.
|
|
77
|
+
minPixelValue: 1.01
|
|
78
|
+
})
|
|
79
|
+
],
|
|
80
|
+
compilerModules: [
|
|
81
|
+
{
|
|
82
|
+
postTransformNode: el => {
|
|
83
|
+
// to convert vnode for weex components.
|
|
84
|
+
require('weex-vue-precompiler')()(el)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> You should use a .js file as your webpack entry, not the Main.vue or App.vue file.
|
|
93
|
+
|
|
94
|
+
The content of your entry file `main.js` should be like this:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// import Vue runtime if you like.
|
|
98
|
+
// import weex-vue-render if you like.
|
|
99
|
+
// init weex if you imported it.
|
|
100
|
+
// at least it should have this:
|
|
101
|
+
import App from './your/App.vue'
|
|
102
|
+
App.el = '#root'
|
|
103
|
+
new Vue(App)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## How to Migrate from 0.12.x to 1.x
|
|
107
|
+
|
|
108
|
+
> Why should I update to 1.x ?
|
|
109
|
+
|
|
110
|
+
The answer is **enoumouse change in rendering performance** with a few minor updates in your code is definitely worth to try.
|
|
111
|
+
|
|
112
|
+
### packing configuration
|
|
113
|
+
|
|
114
|
+
You should use the previous mentioned plugins in your vue-loader configuration.
|
|
115
|
+
|
|
116
|
+
### check your code
|
|
117
|
+
|
|
118
|
+
| category | rules | 0.12.x | 1.x |
|
|
119
|
+
| --- | ---- | ------ | ----- |
|
|
120
|
+
| **render function** | create weex component in render function | support | supported in **>=1.0.11** |
|
|
121
|
+
| **event binding** | bind native events for custom component's root element | `@click` | `@click.native` [doc](https://vuejs.org/v2/guide/components.html#Binding-Native-Events-to-Components) |
|
|
122
|
+
| **styles** | style binding | none | better performance for binding object literal like `:style="{width:w,height:h}"` instead of object variable like `:style="someObj"` |
|
|
123
|
+
| | styles in `animation.transition` | none | should add css prefix manualy if needed. We suggest you use [transition](https://weex-project.io/references/common-style.html#transition-v0-16-0) to implement animation. |
|
|
124
|
+
| **exclusive styles** | limit | none | wirte them in `<style>` tag for better performance. |
|
|
125
|
+
| | `wx` unit | support | only in binding style (will fix soon) |
|
|
126
|
+
| **ref** | what `this.$refs.xx` will get | always instance of VueComponent | HTMLElement for div, image and text; VueComponent for other components. |
|
|
127
|
+
|
|
128
|
+
## Develop
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
# build for weex-vue-render package
|
|
132
|
+
npm run build
|
|
133
|
+
# debug and serve examples
|
|
134
|
+
npm run dev
|
|
135
|
+
# build and run test cases
|
|
136
|
+
npm run test
|
|
137
|
+
```
|