Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/iview/dist/iview.min.js"></script>
<div id="app">
  <i-table :columns="columns1" :data="data1"></i-table>
    <i-table :columns="columns2" :data="data2"></i-table>

</div>

              
            
!

CSS

              
                @import url("//unpkg.com/iview/dist/styles/iview.css");
#app{padding: 32px;}
              
            
!

JS

              
                Vue.directive("mergeRowSpan", {
  inserted: function(el, bind) {
    // 聚焦元素
    el.parentNode.parentNode.rowSpan = bind.value;
  }
});
Vue.directive("mergeColSpan", {
  inserted: function(el, bind) {
    // 聚焦元素
    el.parentNode.parentNode.colSpan = bind.value;
  }
});
Vue.directive("mergeRowSpanDel", {
  inserted: function(el, bind) {
    // 聚焦元素
    el.parentNode.parentNode.remove();
  }
});
var Main = {
  data() {
    return {
      columns1: [
        {
          title: "Name",
          key: "name"
        },
        {
          title: "Age",
          key: "age"
        },
        {
          title: "Address",
          key: "address",
          width: 240,
          render: (h, params) => {
            let attr = null;
            if (params.index === 0) {
              attr = {
                // 自定义指令。注意,你无法对 `binding` 中的 `oldValue`
                // 赋值,因为 Vue 已经自动为你进行了同步。
                directives: [
                  {
                    name: "mergeRowSpan",
                    value: this.data1.length,
                    expression: "1 + 1",
                    arg: "foo",
                    modifiers: {
                      bar: true
                    }
                  }
                ]
              };
            } else {
              attr = {
                // 自定义指令。注意,你无法对 `binding` 中的 `oldValue`
                // 赋值,因为 Vue 已经自动为你进行了同步。
                directives: [
                  {
                    name: "mergeRowSpanDel",
                    value: this.data1.length,
                    expression: "1 + 1",
                    arg: "foo",
                    modifiers: {
                      bar: true
                    }
                  }
                ]
              };
            }
            return h("div", attr, params.row.address);
          }
        }
      ],
      data1: [
        {
          name: "John Brown",
          age: 18,
          address: "New York No. 1 Lake Park",
          date: "2016-10-03"
        },
        {
          name: "Jim Green",
          age: 24,
          address: "London No. 1 Lake Park",
          date: "2016-10-01"
        },
        {
          name: "Joe Black",
          age: 30,
          address: "Sydney No. 1 Lake Park",
          date: "2016-10-02"
        },
        {
          name: "Jon Snow",
          age: 26,
          address: "Ottawa No. 2 Lake Park",
          date: "2016-10-04"
        }
      ],
      columns2: [
         {
          title: "Address",
          key: "address",
          width: 240,
          render: (h, params) => {
            let attr = null;
            console.log(params)
            if (params.index%2) {
              attr = {
                // 自定义指令。注意,你无法对 `binding` 中的 `oldValue`
                // 赋值,因为 Vue 已经自动为你进行了同步。
                directives: [
                  {
                    name: "mergeColSpan",
                    value: 2,
                    expression: "1 + 1",
                    arg: "foo",
                    modifiers: {
                      bar: true
                    }
                  }
                ]
              };
            }
            return h("div", attr, params.row.address);
          }
        }, 
        {
          title: "Name",
          key: "name"
        },
  
            {
          title: "Age",
          key: "age"
        },
      ],
      data2: [
        {
          name: "John Brown",
          age: 18,
          address: "New York No. 1 Lake Park",
          date: "2016-10-03"
        },
        {
          name: "Jim Green",
          age: 24,
          address: "London No. 1 Lake Park",
          date: "2016-10-01"
        },
        {
          name: "Joe Black",
          age: 30,
          address: "Sydney No. 1 Lake Park",
          date: "2016-10-02"
        },
        {
          name: "Jon Snow",
          age: 26,
          address: "Ottawa No. 2 Lake Park",
          date: "2016-10-04"
        }
      ]
    };
  }
};

var Component = Vue.extend(Main);
new Component().$mount("#app");

              
            
!
999px

Console