我应该在哪里放置onChange方法?

时间:2018-04-13 04:25:23

标签: vue.js

在哪里放置iView Switch的on-select方法?

我使用iview Switch作为组件:

我使用渲染功能:

  render: (h, params) => {
    return h('div', [
      // (vm, h, params, fn, btntext)
      h('i-switch',
        {
          props: {
            size:'large',
          },
          // onChange: function (value) {
          //   debugger
          //   context.change_product_item_status_by_user_own_count(params, value)
          // },
          on: {
            onChange: function (value) {
              debugger
            }
          }
        },
        [
          h('span', {slot: 'open'}, 'Open'),
          h('span', {slot: 'close'}, 'Close')
        ])
      ],
    )
  }

但一切都行不通。我应该在哪里将onChange方法放在渲染函数中?

1 个答案:

答案 0 :(得分:0)

来自Vue.js document

  // Event handlers are nested under `on`, though
  // modifiers such as in `v-on:keyup.enter` are not
  // supported. You'll have to manually check the
  // keyCode in the handler instead.
  on: {
    click: this.clickHandler
  },

我看到方法是on-change,所以应该是这样的:

      on: {
        'on-change': function (value) {
          debugger
        }
      }
相关问题