ソースを参照

Updated event name to lowercase hyphen format of vue component

zhixin 6 年 前
コミット
b5076626bd
2 ファイル変更7 行追加3 行削除
  1. 4 2
      site/docs/vuejs/component.md
  2. 3 1
      src/vue/BootstrapTable.vue

+ 4 - 2
site/docs/vuejs/component.md

@@ -14,7 +14,7 @@ toc: true
   :columns="columns"
   :data="data"
   :options="options"
-  @onPostBody="onPostBody"
+  @on-post-body="onPostBody"
 />
 {% endhighlight %}
 
@@ -52,10 +52,12 @@ toc: true
 
 ## Events
 
-The calling method syntax: `@onEvent="onEvent"`.
+The calling method syntax: `@on-event="onEvent"`.
 
 All events (without `onAll`) are defined in [Events API](/docs/api/events/).
 
+**Note:** you need to convert event name to lowercase + hyphen format, for example: `onClickRow` should be `on-click-row`.
+
 ## Methods
 
 The calling method syntax: `this.$refs.table.methodName(parameter)`.

+ 3 - 1
src/vue/BootstrapTable.vue

@@ -32,7 +32,9 @@ export default {
     this.$table = $(this.$el)
 
     this.$table.on('all.bs.table', (e, name, args) => {
-      this.$emit($.fn.bootstrapTable.events[name], ...args)
+      let eventName = $.fn.bootstrapTable.events[name]
+      eventName = eventName.replace(/([A-Z])/g, '-$1').toLowerCase()
+      this.$emit(eventName, ...args)
     })
 
     this._initTable()