JSDM

HTML

 
1
2
<div id="app"></div>
3
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
4
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
5
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
6
7
8

CSS

xxxxxxxxxx
1
 
1
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

xxxxxxxxxx
67
 
1
let data = {
2
  size: 'small'
3
}
4
let methods = {
5
  clickHandler() {
6
  }
7
}
8
Object.assign(window, data, methods)
9
// 契约数据
10
const vdom = {
11
  vid: 'root',
12
  tag: 'div',
13
  attrs: {
14
  },
15
  children: [{
16
    vid: 'fe5s1f5gegr4',
17
    tag: 'el-row',
18
    attrs: {},
19
    children: [{
20
      vid: 'qwef5g165hse',
21
      tag: 'el-col',
22
      attrs: {
23
        span: 12
24
      },
25
      children: [{
26
        vid: '526g4h1fg2hj1',
27
        tag: 'el-button',
28
        attrs: {
29
          size: this.size,
30
          icon: 'el-icon-plus',
31
          type: 'primary'
32
        },
33
        on: {
34
          click: this.clickHandler
35
        },
36
        text: '按钮'
37
      }]
38
    }]
39
  }]
40
}
41
// 契约转vnode
42
const dataToVnode = (createElement, data) => {
43
  let children = []
44
  if (data.children && data.children.length) {
45
    children = data.children.map(item => dataToVnode(createElement, item))
46
  } else {
47
    children = data.text
48
  }
49
  return createElement(data.tag, {
50
    attrs: {
51
      ...data.attrs,
52
      vid: data.vid
53
    },
54
    on: {
55
      ...data.on
56
    }
57
  }, children)
58
}
59
// 生成vnode
60
const vnode = {
61
  render(createElement) {
62
    return dataToVnode(createElement, vdom)
63
  }
64
}
65
new Vue({
66
  render: h => h(vnode)
67
}).$mount('#app')
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................